Amazon API Gateway to AWS Step Functions

API Gateway HTTP API → Step Functions

Create an API Gateway HTTP APIs endpoint that starts a Step Functions syncronous Express Workflow

The SAM template deploys a HTTP APIs endpoint with an integration that syncronsouly invokes a Step Functions Express workflow and returns the response. The SAM template contains the minimum IAM resources required to run the application with logging enabled.
The HTTP's API endpoint can be called from an application (e.g. a web front end) to run an express workflow and return the result.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-sfn

Deploy

sam deploy --guided


Testing

Run the following command to send an HTTP `POST` request to the HTTP APIs endpoint. Note, you must edit the {HelloWorldApi} placeholder with the URL of the deployed HTTP APIs endpoint. This is provided in the stack outputs:
curl --location --request POST '{HelloWorldApi}' --header 'Content-Type: application/json' --data-raw '{ "IsHelloWorldExample": "Yes" }'

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:

Benjamin Smith

Benjamin Smith

Ben is a senior developer advocate for Serverless Applications at Amazon Web Services based in London, UK. Prior to joining AWS Ben worked in a number of different technical roles specializing in workflow Automation and web development.

Follow on LinkedIn