Reputation: 997
I have created a lambda and s3 event rule using cloudformation but lambda is not getting triggered as per configured rule. As per event rule I want lambda to trigger whenever a file is created in a specific s3 bucket with a specific suffix. Rule is given permission to invoke lambda. But when I upload a file (e.g. portfolio.testSuffix) lambda is not getting triggered.
EventRule:
Type: AWS::Events::Rule
Properties:
Description: 'test s3 event'
EventPattern:
source:
- 'aws.s3'
detail:
eventSource:
- 's3.amazonaws.com'
eventName:
- 'CopyObject'
- 'PutObject'
requestParameters:
bucketName:
- 'test-bucket'
key:
- |
{"suffix": ".testsuffix"}
State: 'ENABLED'
Targets:
-
Arn: !GetAtt TestLambda.Arn
Id: 'TestLambdaTargetId'
LambdaInvokePermission:
Type: AWS::Lambda::Permission
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !GetAtt TestLambda.Arn
Principal: 'events.amazonaws.com'
SourceArn: !GetAtt EventRule.Arn
Can anyone help to identify what is wrong in this configuration and why lambda is not getting triggered ?
Upvotes: 0
Views: 3035
Reputation: 191
It seems that support for suffix was recently added, based on the documentation.
Comparison | Example | Rule syntax |
---|---|---|
Ends with | FileName ends with a .png extension. | "FileName": [ { "suffix": ".png" } ] |
reference: Content-based filtering
Upvotes: 3
Reputation: 353
According to the Eventbridge documentation the suffix pattern is not supported.
key:
- |
{"suffix": ".testsuffix"}
Here's a list of all the comparison operators available in EventBridge:
Null, Empty, Equals, And, Or, Not, Numeric (equals), Numeric (range), Exists, Does not exist, Begins with
See Content-based filtering as well
Upvotes: 3