0

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 ?

2 Answers 2

4

As @Aris answers highlights, EventBridge does support suffix matching as well, as stated in the documentation.


Old answer from 2021

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.