What is the format of AWS::Events::Rule to kick off a Lambda function when a file comes into an S3 bucket folder?

1

What is needed in the template to create a rule to kick off a lambda function when a file comes in to an S3 bucket. I know the details to S3 bucket and Lambda function / ARN are needed but not sure what the syntax of some of the details are. I've included some questions and what I extrapolated from the example in the documentation (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern) but unsure how it ties to the Lambda function and built into the CodePipeline. Is it: S3 bucket, S3 Code deploy, Lambda function, Event trigger, Glue Job?

Type: AWS::Events::Rule Properties:

Description: String

EventBusName: ?

EventPattern: ? # syntax needed here:

           +  prefix   (prefix of the folder path)
                                       
           +  suffix   (file type .parquet)

Name: String

RoleArn: # ARN to the role we are using which needs permissions to kick off lambda

State: Enabled

Targets:

- Target  :                #target of the lambda function (ARN and Id)
AllMur
gefragt vor einem Jahr378 Aufrufe
2 Antworten
0

You need to provide JSON EventBridge Event pattern:

{
    "source": [  "aws.s3" ],
    "detail-type": [  "Object Created" ],
    "detail": {
        "bucket": {
            "name": [ "yourbucketname" ]
        }    
  }
}

By the way you can trigger Lambda directly from S3 Events -> Lambda https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html

profile picture
EXPERTE
beantwortet vor einem Jahr
profile picture
EXPERTE
überprüft vor einem Jahr
  • Is this in addition to AWS::Events::Rule ?

0

In CloudFormation syntax it will be like this:

  YourEventRule:
    Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - aws.s3
        detail-type:
          - 'Object Created'
        detail:
          bucket:
             name:
               - 'yourbucketname'
profile picture
EXPERTE
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen