I need to create EventBridge Rule detecting stopped ECS Task and sending info to SNS Topic.
- When I create the Rule manually, it works
- When I create the same rule via Pulumi, it does not work - it does not match any events
They are both exactly the same. I even compared the exported CloudFormation template, they are both the same. What can be different and how can I spot or fix the difference?
Here's the CF template:
AWSTemplateFormatVersion: '2010-09-09'
Description: CloudFormation template for EventBridge Rule ecsSlackAlertsEventRule
Resources:
Rule88730153:
Type: AWS::Events::Rule
Properties:
Name: ecsSlackAlertsEventRule
EventPattern: >-
{"detail":{"clusterArn":["arn:aws:ecs:us-west-2:xxxxxxxxxxx:cluster/ecs-14f72ee"],"lastStatus":["STOPPED"]},"detailType":["ECS
Task State Change"],"source":["aws.ecs"]}
State: ENABLED
EventBusName: default
Targets:
- Id: xxxxxxxxxxx-ad6a-46d2-912f-071ec8da74f2
Arn:
Fn::Sub: >-
arn:${AWS::Partition}:sns:${AWS::Region}:${AWS::AccountId}:ecs-slack-notifications
Parameters: {}
And the Pulumi code:
const ecsAlertEventRule = new aws.cloudwatch.EventRule("ecsSlackAlertsEventRule", {
name: "ecsSlackAlertsEventRule",
eventBusName: "default",
eventPattern: ecsCluster.arn.apply(arn => {
return JSON.stringify({
source: ["aws.ecs"],
detailType: ["ECS Task State Change"],
detail: {
clusterArn: [arn],
lastStatus: ["STOPPED"],
}
})
}),
});
const ecsAlertEventTarget = new aws.cloudwatch.EventTarget("ecsSlackAlertsEventTarget", {
rule: ecsAlertEventRule.name,
arn: slackNotificationsSNSTopic.arn,
});