AWS Lambda to AWS Step Functions

AWS Lambda → AWS Step Functions

Invoke an AWS Step Functions workflow from AWS Lambda, with logging enabled

The SAM template deploys a Lambda function, a Step Functions Express workflow, a Log group and the IAM resources required to run the application. A Lambda function uses the AWS SDK to asyncronously invoke the Express workflow, passing the event body as a string. The Express Workflow results are logged in Amazon CloudWatch Logs. The Lambda function returns the Express Workflow execution ARN and startDate.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub

Variants

This pattern is available in the following frameworks/languages:

AWS SAM:JavaNode.jsRust
Serverless Framework:TypeScript
Terraform:Python
Terraform (with modules):Python

Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-sfn/java/sam

Deploy

sam deploy --guided


Testing

Run the following Lambda CLI invoke command to invoke the function. Note, you must edit the {LambdaProxyArn} placeholder with the ARN of the deployed Lambda function. This is provided in the stack outputs.
aws lambda invoke --function-name {LambdaProxyArn} --invocation-type Event --payload '{ "IsHelloWorldExample": "Hello" }' response.json --cli-binary-format raw-in-base64-out

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Razvan Minciuna

Razvan Minciuna

Software Architect.