MasterOfTheHouse
MasterOfTheHouse

Reputation: 1329

Serverless Framework and how to enable AWS State Machine to be called by an S3 event rule

As per the documentation of the Serverless Framework plugin, See examples here we are able to enable our Statemachine to be called by an EC2 event rule.

(From above link )

stepFunctions:
  stateMachines:
    first:
      events:
        - cloudwatchEvent:
            event:
              source:
                - "aws.ec2"
              detail-type:
                - "EC2 Instance State-change Notification"
              detail:
                state:
                  - pending
      definition:
        ...

I want my State Machine to be called from an S3 event rule.

However, as per AWS CloudWatch Even Types documentation, it does not look like we are able to use the S3 event rule as it does not appear in AWS CloudWatch Even Types documentation link

So does it means I can not use this plug-in to call my State machine based on an S3 event rule, like for example a new object uploaded to S3 ??

Upvotes: 0

Views: 444

Answers (1)

JD D
JD D

Reputation: 8087

It depends on the types of S3 events you are trying to trigger from.

The link you provided shows that you can use CloudTrail events to trigger CloudWatch event rules. This would allow you to trigger on events such as creating/removing buckets.

If you want to trigger off of things like objects being added/deleted from a bucket, then you will not be able to do it without writing some additional resources. You can create S3 events to trigger SQS, SNS or a Lambda function. My suggestion would be to implement a lambda function that accepts an S3 event and kicks off your state machine as desired. Then create an S3 event to trigger your lambda when the desired object event occurs.

Upvotes: 1

Related Questions