Amazon Step Functions and Amazon SAM - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon Step Functions and Amazon SAM

You can use the Amazon SAM CLI in conjunction with the Amazon Toolkit for Visual Studio Code as part of an integrated experience to create state machines locally. You can build a serverless application with Amazon SAM, then build out your state machine in the VS Code IDE. Then you can validate, package, and deploy your resources. Optionally, you can also publish to the Amazon Serverless Application Repository.

Tip

To deploy a sample serverless application that starts a Step Functions workflow using Amazon SAM to your Amazon Web Services account, see Module 11 - Deploy with Amazon SAM of The Amazon Step Functions Workshop.

Why use Step Functions with Amazon SAM?

When you use Step Functions with Amazon SAM you can:

  • Get started using a Amazon SAM sample template.

  • Build your state machine into your serverless application.

  • Use variable substitution to substitute ARNs into your state machine at the time of deployment.

  • Specify your state machine's role using Amazon SAM policy templates.

  • Initiate state machine executions with API Gateway, EventBridge events, or on a schedule within your Amazon SAM template.

Step Functions integration with the Amazon SAM specification

You can use the Amazon SAM Policy Templates to add permissions to your state machine. With these permissions, you can orchestrate Lambda functions and other Amazon resources to form complex and robust workflows.

Step Functions integration with the SAM CLI

Step Functions is integrated with the Amazon SAM CLI. Use this to quickly develop a state machine into your serverless application.

Try the Create a Step Functions State Machine Using Amazon SAM tutorial to learn how to use Amazon SAM to create state machines.

Supported Amazon SAM CLI functions include:

CLI Command Description
sam init

Initializes a Serverless Application with an Amazon SAM template. Can be used with a SAM template for Step Functions.

sam validate Validates an Amazon SAM template.
sam package

Packages an Amazon SAM application. It creates a ZIP file of your code and dependencies, and then uploads it to Amazon S3. It then returns a copy of your Amazon SAM template, replacing references to local artifacts with the Amazon S3 location where the command uploaded the artifacts.

sam deploy Deploys an Amazon SAM application.
sam publish

Publish an Amazon SAM application to the Amazon Serverless Application Repository. This command takes a packaged Amazon SAM template and publishes the application to the specified region.

Note

When using Amazon SAM local, you can emulate Lambda and API Gateway locally. However, you can't emulate Step Functions locally using Amazon SAM.

You can learn more about using Step Functions with Amazon SAM with the following resources: