Trigger a State Machine execution in response to a S3 event

Recently, we presented some conclusions we found interesting and relevant about Step Functions and one plus for us is its integration with other AWS services, especially AWS CloudWatch and Lambda. On the other hand, at this moment Step Functions doesn’t offer support to trigger an execution in response to an event occurred in AWS, like it could be configured Lambda, the only option being to explicitly invoke an execution using the AWS SDK.

This may seem like a huge problem at first, but it can be very easily solved by wiring an event to a Lambda function and configure it to behave as a proxy that redirects its input to the target step function.

In this post we want to show you how an implementation for S3 events and in the next period we’ll extend support for other services as well.

So, let’s see the steps to setup our solution.
1. Fetch code available here and build it, as it’s described in the documentation
2. Create a Lambda function using the artifacts generated above and using the handler:
3. Add an environment variable to the Lambda function with details about Step Function credentials, state machine name and the AWS region where to run it. We’ll use Java system properties, as we described in another post. So, the variable is named JAVA_TOOL_OPTIONS and its value is -Daws.accessKeyId=<> -Daws.secretKey=<> -DstateMachineARN=<> -DawsRegion=<>
4. Configure the S3 events to trigger the Lambda function defined above.

We invite you to help us extending this project with support for other events! As always, we encourage your feedback in the below section! Thank you for following us!

One thought on “Trigger a State Machine execution in response to a S3 event

  1. This is the perfect site for anyone who wishes to find out about this topic.
    You know so much its almost tough to argue with you (not that I
    actually will need to…HaHa). You certainly put a fresh spin on a subject which has been written about
    for ages. Excellent stuff, just wonderful!

Comments are closed.