gammarers-aws-cdk-resources/ecs-fargate-task-termination-detection-event-rule
GitHub: gammarers-aws-cdk-resources/ecs-fargate-task-termination-detection-event-rule
一个AWS CDK构造,用于通过EventBridge规则检测ECS/Fargate任务非正常终止(容器退出码非零)并排除预期的扩缩容停止事件。
Stars: 0 | Forks: 0
# ECS Fargate 任务终止检测事件规则 (AWS CDK V2)
[](https://github.com/gammarers-aws-cdk-resources/ecs-fargate-task-termination-detection-event-rule/blob/main/LICENSE)
[](https://www.npmjs.com/package/ecs-fargate-task-termination-detection-event-rule)
[](https://github.com/gammarers-aws-cdk-resources/ecs-fargate-task-termination-detection-event-rule/actions/workflows/release.yml)
[](https://github.com/gammarers-aws-cdk-resources/ecs-fargate-task-termination-detection-event-rule/releases)
[](https://constructs.dev/packages/ecs-fargate-task-termination-detection-event-rule)
一个 AWS CDK 构造,用于创建 Amazon EventBridge 规则来检测 ECS/Fargate 任务终止(非零容器退出码),同时排除预期的扩展事件。
## 功能
- 检测 `lastStatus` 为 `STOPPED` 的 ECS 任务状态变化
- 过滤非零容器退出码
- 排除常见的预期扩展停止原因
## 安装
### TypeScript
**npm**
```
npm install ecs-fargate-task-termination-detection-event-rule
```
**yarn**
```
yarn add ecs-fargate-task-termination-detection-event-rule
```
## 使用方法
```
import { EcsFargateTaskTerminationDetectionEventRule } from 'ecs-fargate-task-termination-detection-event-rule';
const clusterArn = 'arn:aws:ecs:us-east-1:123456789012:cluster/example-app-cluster';
const rule = new EcsFargateTaskTerminationDetectionEventRule(stack, 'EcsFargateTaskTerminationDetectionEventRule', {
description: 'example event rule.',
clusterArn,
});
```
## 选项
- `clusterArn`(必需):要监控的 ECS 集群 ARN
- 其他 `RuleProps` 选项(例如 `description`、`enabled`、`ruleName`、`targets`)可以按常规方式提供。
- `eventPattern`:不支持。此构造始终定义自己的 `eventPattern`,如果您提供将会抛出异常。
## 依赖要求
- Node.js `>= 20`
- AWS CDK `aws-cdk-lib` v2
- `constructs` v10
## 许可证
本项目基于 (Apache-2.0) 许可证授权。
标签:AWS CDK, AWS CDK V2, AWS云, ECS, EventBridge, Fargate, MITM代理, Terraform, TypeScript, 事件驱动, 任务终止检测, 安全插件, 容器监控, 容器退出码, 异常检测, 无服务器, 自动化攻击, 自动化运维, 运维监控