-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-ecr): ECR EventBridge rule has incorrect event pattern #29225
(aws-ecr): ECR EventBridge rule has incorrect event pattern #29225
Comments
Also, CDK adds the ecrRepo.OnEvent("EcrRepoEventRule", new OnEventOptions() {
Target = new LambdaFunction(ecrHandler),
EventPattern = new EventPattern() {
Source = new[] { "aws.ecr" },
Resources = null, //Setting to `null` or `new string[0]` doesn't help
Detail = new Dictionary<string, object>() {
["repository-name"] = new[] { ecrRepo.RepositoryName },
},
},
}); Result: {
"resources": ["arn:aws:ecr:ap-southeast-2:<account-id>:repository/repository-name"],
"detail": {
"repository-name": ["repository-name"]
},
"source": ["aws.ecr"]
} |
Workaround is to create the rule directly via the EventBridge CDK new Rule(this, "EcrRepoEventRule", new RuleProps() {
Targets = new IRuleTarget[] {
new LambdaFunction(ecrHandler),
},
EventPattern = new EventPattern() {
Source = new[] { "aws.ecr" },
Detail = new Dictionary<string, object>() {
["repository-name"] = new[] { ecrRepo.RepositoryName },
},
},
}); |
Yes I get this when I synth: Type: AWS::Events::Rule
Properties:
EventPattern:
source:
- aws.ecr
resources:
- Fn::GetAtt:
- CiTestEcrRepository95B2A864
- Arn
State: ENABLED
Targets:
- Arn:
Fn::GetAtt:
- Func217E03A4
- Arn
Id: Target0 And looks like the resources should be empty according to the doc. And we probably should filter the |
I'll take this. |
@pahud I started a PR for this but please see my comment in the description. The Lambda trigger does not created on the Lambda side. |
Closes #29225. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
Using the CDK, creating an EventBridge rule on an ECR repository creates a rule with the following event pattern:
However when ECR sends the event,
"resources"
is empty, so the rule never matches (example from https://docs.aws.amazon.com/AmazonECR/latest/userguide/ecr-eventbridge.html#ecr-eventbridge-bus):Expected Behavior
Use the
detail.repository-name
field as a filter instead ofresources
:Current Behavior
Uses
resources
as a filter, which is empty in the real eventReproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.127.0 (build 6c90efc)
Framework Version
.NET 8
Node.js Version
v18.16.1
OS
MacOS
Language
.NET
Language Version
.NET 8
Other information
No response
The text was updated successfully, but these errors were encountered: