☁️
AWS Reference Notes
  • About
    • README
  • Compute
    • Amazon EC2
      • Common
        • Monitor
        • Networking
        • Security
        • Resources and tags
        • Troubleshoot
      • Topics
        • Amazon Machine Images
        • Instances
        • Storage
    • Amazon EC2 Image Builder
      • Common
      • Topics
        • Get started
        • AWSTOE component manager
        • Manage resources
        • Manage pipelines
        • Integrate products and services
        • Security in EC2 Image Builder
    • AWS End-of-Support Migration Program (EMP) for Windows Server
      • Common
      • Topics
        • Get started
        • Working with EMP packages
    • AWS ParallelCluster
      • Common
      • Topics
        • AWS ParallelCluster version 2
    • AWS Serverless Application Model (AWS SAM)
      • Common
        • Getting started
        • Monitoring
      • Topics
        • AWS SAM specification
        • Authoring
        • Building
        • Testing and debugging
        • Deploying
        • Publishing
        • Example applications
        • AWS CDK
        • AWS SAM reference
    • AWS Serverless Application Repository
      • Common
      • Topics
        • Publishing Applications
        • Deploying Applications
  • Serverless
    • Amazon S3
      • Common
        • Getting started
        • Tutorials
        • Security
        • Monitoring Amazon S3
        • Developing with Amazon S3
        • Troubleshooting
      • Topics
        • Working with buckets
        • Working with objects
        • Working with access points
        • Working with Multi-Region Access Points
        • Managing storage
        • Using analytics and insights
        • Hosting a static website
    • AWS Lambda
      • Common
        • Configuring functions
        • Access permissions
        • Monitoring functions
        • Troubleshooting
      • Topics
        • Lambda foundations
        • Lambda runtimes
        • Deploying functions
        • Invoking functions
        • Managing functions
        • Building with Node.js
        • Building with TypeScript
        • Building with Python
        • Building with Ruby
        • Building with Java
        • Building with Go
        • Building with C#
        • Building with PowerShell
        • Integrating other services
        • Creating container images
        • Lambda extensions
        • Lambda applications
        • Orchestrating functions
  • Database
    • Amazon Aurora
      • Common
        • What is Aurora?
        • Getting started
        • Configuring your Aurora DB cluster
        • Monitoring metrics in an Aurora DB cluster
        • Monitoring events, logs, and database activity streams
        • Security
      • Topics
        • Managing an Aurora DB cluster
        • Using Blue/Green Deployments for database updates
        • Backing up and restoring an Aurora DB cluster
        • Working with Aurora MySQL
        • Working with Aurora PostgreSQL
        • Using RDS Proxy
        • Using Aurora Serverless v2
        • Using Aurora Serverless v1
    • Amazon RDS
      • Common
        • What is Amazon RDS?
        • Getting started
        • Configuring a DB instance
        • Configuring and managing a Multi-AZ deployment
        • Monitoring metrics in a DB instance
        • Monitoring events, logs, and database activity streams
        • Security
      • Topics
        • Managing a DB instance
        • Using Blue/Green Deployments for database updates
        • Backing up and restoring
        • Working with Amazon RDS Custom
        • Working with RDS on AWS Outposts
        • Using RDS Proxy
        • MariaDB on Amazon RDS
        • Microsoft SQL Server on Amazon RDS
        • MySQL on Amazon RDS
        • Oracle on Amazon RDS
        • PostgreSQL on Amazon RDS
  • Machine Learning
    • Amazon SageMaker
      • Common
        • Security
        • Monitoring
      • Topics
        • What Is Amazon SageMaker?
        • Get Started
        • Machine Learning Environments
        • Autopilot: Automated ML
        • Label Data
        • Prepare and Analyze Datasets
        • Create, Store, and Share Features
        • Training
        • Deploy Models for Inference
        • Docker containers with SageMaker
        • Augmented AI
        • Marketplace
    • Amazon CodeGuru
      • Common
        • Getting started
        • Security
      • Topics
        • Setting up
        • Working with repository associations
        • Working with code reviews
    • Amazon Comprehend Medical
      • Common
      • Topics
        • Text analysis APIs
        • Ontology Linking APIs
    • Amazon Forecast
      • Common
        • Getting Started
      • Topics
        • Setting Up
        • Importing Datasets
        • Training Predictors
        • Managing Resources
    • Amazon Kendra
      • Common
        • Getting started
      • Topics
        • How Amazon Kendra works
        • Searching indexes
        • Adding custom synonyms to an index
        • Tutorial: Building an intelligent search solution
    • Amazon Lex
      • Common
        • Getting Started
      • Topics
        • How It Works
        • Using Lambda Functions
        • Deploying Bots
        • Importing and Exporting
        • Bot Examples
    • Amazon Lookout for Vision
      • Common
      • Topics
        • Setting up Amazon Lookout for Vision
        • Creating your model
        • Improving your model
        • Running your model
        • Using your model on an edge device
        • Managing your resources
        • Example code and datasets
    • AWS Panorama
      • Common
        • Getting started
        • Monitoring
      • Topics
        • Permissions
        • Appliance
        • Building applications
    • Amazon Personalize
      • Common
      • Topics
        • Filtering results
    • Amazon Polly
      • Common
      • Topics
        • Voices in Amazon Polly
        • Neural TTS
        • Speech Marks
        • Using SSML
        • Amazon Polly for Windows (SAPI)
    • Amazon Rekognition
      • Common
        • Getting started
        • Tutorials
        • Security
      • Topics
        • How it works
        • Detecting and analyzing faces
        • Searching faces in a collection
        • Recognizing celebrities
        • Moderating content
        • Detecting text
        • Detecting video segments
    • Amazon Textract
      • Common
        • Getting Started
        • Security
      • Topics
        • How It Works
        • Processing Documents with Synchronous Operations
        • Processing Documents with Asynchronous Operations
        • Amazon A2I and Amazon Textract
        • Quotas
    • AWS Deep Learning AMIs
      • Common
        • Getting Started
      • Topics
        • What Is the AWS Deep Learning AMI?
        • Launching a DLAMI
        • Using a DLAMI
        • Upgrading Your DLAMI
    • AWS Deep Learning Containers
      • Common
      • Topics
        • Getting Started With Deep Learning Containers
        • Deep Learning Containers Resources
    • AWS DeepLens
      • Common
      • Topics
        • Managing Your Device
    • AWS DeepRacer
      • Common
      • Topics
        • How it works
        • Operate your vehicle
        • Join a race
        • Tagging
        • Troubleshoot common issues
  • Containers
    • AWS App Runner
      • Common
        • Networking
      • Topics
        • Managing your service
        • Observability
        • App Runner configuration file
        • App Runner API
    • Amazon ECS
      • Common
        • Getting started
        • Resources and tags
        • Monitoring
        • Working with other services
        • Tutorials
        • Troubleshooting
      • Topics
        • Developer tools overview
        • Clusters
        • Task definitions
        • Account settings
        • Container instances
        • Container agent
        • Scheduling tasks
        • Services
  • Storage
    • Amazon EBS
      • Common
        • Monitor
        • Networking
        • Security
        • Resources and tags
        • Troubleshoot
      • Topics
        • Amazon Machine Images
        • Instances
        • Storage
    • Amazon EFS
      • Common
        • Getting started
        • Security
      • Topics
        • Working with EFS resources
        • Using amazon-efs-utils
        • Mounting file systems
        • Transferring data
        • Managing file systems
        • EFS backups
        • Walkthroughs
        • Troubleshooting Amazon EFS
        • Additional information
    • Amazon S3 Glacier
      • Common
        • Getting Started
      • Topics
        • What Is Amazon S3 Glacier?
        • Working with Vaults
        • Working with Archives
        • Using the AWS SDKs
        • API Reference
  • Migration & Transfer
    • AWS Snow Family
      • Common
        • What is Snowball Edge?
        • Getting Started
        • Security
      • Topics
        • Large Data Migration
        • Using AWS OpsHub to Manage Devices
        • Using a Snowball Edge Device
        • Using Snow Device Management to Manage Devices
        • Understanding AWS Snowball Edge Jobs
        • Best Practices
        • Quotas
    • AWS Application Discovery Service
      • Common
      • Topics
        • Setting up
        • Discovery Agent
        • View, export & explore data
        • Console Walkthroughs
        • Appendix
    • AWS Database Migration Service
      • Common
        • Getting started
        • Security
      • Topics
        • Working with replication instances
        • Endpoints
        • Tasks
        • Troubleshooting and diagnostic support
        • Reference
    • AWS DataSync
      • Common
        • Getting started
        • Security
        • Tutorials
      • Topics
        • Requirements
        • Working with agents
        • Discovering your storage
        • Transferring your data
        • Using the AWS CLI
    • AWS Migration Hub
      • Common
        • Getting started
      • Topics
    • AWS Transfer Family
      • Common
        • Configuring AS2
        • Security
      • Topics
        • Setting up
        • Creating a server
        • Managing users
        • Managing workflows
        • Managing servers
        • API reference
  • Security, Identity, & Compliance
    • AWS Identity and Access Management (IAM)
      • Common
        • What is IAM?
        • Tutorials
        • Security
      • Topics
        • Identities
        • Access management
        • Troubleshooting IAM
        • Reference
    • Amazon Cognito
      • Common
        • Tutorials
        • Security
      • Topics
        • Amazon Cognito user pools
        • Amazon Cognito identity pools
        • Amazon Cognito Sync
    • AWS IAM Identity Center (successor to AWS Single Sign-On)
      • Common
        • Getting started
      • Topics
        • Workforce identities
        • Multi-account permissions
        • Application assignments
        • Resiliency design and Regional behavior
    • AWS Resource Access Manager (AWS RAM)
      • Common
        • Getting started
        • Troubleshooting
      • Topics
        • Working with shared resources
        • Managing permissions in AWS RAM
    • AWS Secrets Manager
      • Common
      • Topics
        • Create and manage secrets
        • Retrieve secrets
        • Rotate secrets
        • Security in Secrets Manager
    • AWS WAF
      • Common
      • Topics
        • AWS WAF
        • AWS WAF Classic
        • AWS Shield
  • Cryptography & PKI
    • AWS Cryptographic Services Overview
      • Common
      • Topics
        • AWS cryptographic services and tools
    • AWS CloudHSM
      • Common
        • Getting started
        • Troubleshooting
      • Topics
        • Managing clusters
        • Managing backups
        • Integrating third-party applications
    • AWS Key Management Service (AWS KMS)
      • Common
      • Topics
        • AWS Key Management Service
        • Managing keys
        • Authentication and access control
        • Special-purpose keys
        • Quotas
        • How AWS services use AWS KMS
        • Programming the AWS KMS API
    • AWS Private Certificate Authority
      • Common
        • What is AWS Private CA?
        • Security
      • Topics
        • Planning a private CA
        • CA administration
        • Certificate administration
        • Using the API (Java examples)
  • Management & Governance
    • AWS Chatbot
      • Common
        • Getting started
        • Monitoring AWS services
        • Monitoring AWS Chatbot
        • Security
      • Topics
        • Understanding permissions
        • Performing actions
    • AWS Command Line Interface (AWS CLI)
      • Common
        • Getting started
        • Configuring the AWS CLI
      • Topics
        • Authentication and access credentials
        • Using the AWS CLI
        • Using the AWS CLI with AWS Services
    • AWS Config
      • Common
      • Topics
        • What Is AWS Config?
        • Using AWS Config
        • AWS Config Rules
        • Conformance Packs
        • Multi-Account Multi-Region Data Aggregation
    • AWS Control Tower
      • Common
        • Getting started
        • Security
      • Topics
        • What Is AWS Control Tower?
        • Best practices for administrators
        • Automate tasks
        • Customize your landing zone
        • Configure Regions
        • Accounts
        • Drift
        • Organizations
        • Controls reference guide
        • Integrated services
        • Logging and monitoring
        • Walkthroughs
        • Release notes
    • AWS Health
      • Common
      • Topics
        • Aggregating AWS Health events
    • AWS Launch Wizard
      • Common
        • Security
      • Topics
        • AWS Launch Wizard for Amazon Elastic Kubernetes Service
        • AWS Launch Wizard for Exchange Server
        • AWS Launch Wizard for Internet Information Services
        • AWS Launch Wizard for Remote Desktop Gateway
        • AWS Launch Wizard for SAP
    • AWS Resource Groups
      • Common
      • Topics
        • Resource groups
  • Networking & Content Delivery
    • Amazon API Gateway
      • Common
      • Topics
        • Working with REST APIs
        • Working with HTTP APIs
        • Working with WebSocket APIs
        • OpenAPI extensions
        • Tagging
    • AWS App Mesh
      • Common
        • Getting started
        • Troubleshooting
      • Topics
        • Concepts
        • Envoy
        • Observability
        • Securing Applications
    • AWS Direct Connect
      • Common
        • What is AWS Direct Connect?
      • Topics
        • Using the AWS Direct Connect Resiliency Toolkit to get started
        • Connections
        • Virtual interfaces
        • LAGs
        • Working with Direct Connect gateways
    • Amazon Route 53
      • Common
        • Getting started
        • Configuring Amazon Route 53 as your DNS service
        • What is Route 53 Resolver?
        • Monitoring
        • Troubleshooting
        • Tutorials
      • Topics
        • Registering and managing domains
        • Routing internet traffic to your AWS resources
        • Creating health checks and configuring DNS failover
  • Application Integration
    • AWS Step Functions
      • Common
        • Tutorials
        • Working with other services
        • Troubleshooting
      • Topics
        • How Step Functions works
        • Workflow Studio
        • Developer tools
        • Best practices
        • Sample projects for Step Functions
        • Logging and monitoring
  • Developer Tools
    • AWS Cloud9
      • Common
        • Security
      • Topics
        • Setting up
        • Working with environments
        • Working with the IDE
        • Working with other AWS services
        • Visual source control with Git panel
        • AWS Toolkit
        • Tutorials and samples
        • Advanced topics
    • AWS CodeArtifact
      • Common
        • Security
      • Topics
        • Working with repositories
        • Working with upstream repositories
        • Working with packages
        • Working with domains
        • Using npm
        • Using Python
        • Using Maven
        • Using NuGet
        • Using CodeArtifact with CodeBuild
        • Working with VPC endpoints
    • AWS CodeDeploy
      • Common
        • What is CodeDeploy?
        • Getting started
        • Tutorials
        • Security
        • Troubleshooting
      • Topics
        • Product and service integrations
        • Working with instances
        • Working with application revisions
        • Working with deployments
        • Reference
    • AWS CodeStar
      • Common
      • Topics
        • Getting Started with AWS CodeStar
        • Working with Projects
        • Working with Teams
        • Working with Your AWS CodeStar User Profile
    • Porting Assistant for .NET
      • Common
      • Topics
        • Get Started
        • Porting Assistant for .NET Visual Studio IDE extension
    • AWS X-Ray
      • Common
        • Security
      • Topics
        • X-Ray console
        • X-Ray API
        • Sample application
        • X-Ray daemon
        • Integrating with AWS services
        • Working with Go
        • Working with Node.js
        • Working with Python
        • Working with .NET
  • Media Services
    • Amazon Elastic Transcoder
      • Common
      • Topics
        • Working with Pipelines
        • Working with Jobs
        • Working with Presets
        • Securing Your Content
        • API Reference
  • Internet of Things (IoT)
    • AWS IoT Device Defender
      • Common
        • Security
        • Monitoring AWS IoT
        • Troubleshooting
      • Topics
        • Getting started with AWS IoT Core
        • Connecting to AWS IoT Core
        • Managing devices with AWS IoT
        • Tagging your AWS IoT resources
        • Rules
        • Device Shadow service
        • Jobs
        • AWS IoT secure tunneling
        • Device provisioning
        • Fleet indexing
        • MQTT-based file delivery
        • AWS IoT Device Defender
        • Device Advisor
        • Event messages
        • AWS IoT Core for LoRaWAN
        • Event notifications for AWS IoT Wireless
    • AWS IoT Device Management
      • Common
        • Security
        • Monitoring AWS IoT
        • Troubleshooting
      • Topics
        • Getting started with AWS IoT Core
        • Connecting to AWS IoT Core
        • Managing devices with AWS IoT
        • Tagging your AWS IoT resources
        • Rules
        • Device Shadow service
        • Jobs
        • AWS IoT secure tunneling
        • Device provisioning
        • Fleet indexing
        • MQTT-based file delivery
        • AWS IoT Device Defender
        • Device Advisor
        • Event messages
        • AWS IoT Core for LoRaWAN
        • Event notifications for AWS IoT Wireless
    • AWS IoT Events
      • Common
        • Tutorials
        • Monitoring with alarms
        • Troubleshooting
      • Topics
        • Supported actions
        • Expressions
    • AWS IoT Greengrass
      • Common
        • What is AWS IoT Greengrass?
        • Tutorials
        • Security
      • Topics
        • Setting up Greengrass core devices
        • Components
        • Logging and monitoring
        • Run Lambda functions
        • Communicate with the Greengrass nucleus, other components, and AWS IoT Core
        • Interact with local IoT devices
        • Interact with device shadows
        • Manage data streams
        • Perform machine learning inference
        • Manage core devices with AWS Systems Manager
        • Using AWS IoT Device Tester for AWS IoT Greengrass V2
    • AWS IoT SiteWise
      • Common
        • Getting started
        • Tutorials
        • Monitoring data with alarms
        • Monitoring data with web portals
        • Security
        • Troubleshooting
      • Topics
        • Ingesting data to AWS IoT SiteWise
        • Using AWS IoT SiteWise gateways
        • Modeling industrial assets
        • Managing data ingestion
        • Interacting with other services
        • Logging and monitoring
        • Endpoints and quotas
  • Business Applications
    • Amazon Chime SDK
      • Common
      • Topics
        • Using the Amazon Chime SDK
        • Using Amazon Chime SDK meetings
        • Using Amazon Chime SDK messaging
  • Analytics
    • Amazon CloudSearch
      • Common
        • Getting Started
      • Topics
        • What Is Amazon CloudSearch?
        • Creating and Managing Search Domains
        • Controlling How Data is Indexed
        • Uploading and Indexing Data
        • Searching Your Data
        • Querying For More Information
        • Controlling Search Results
        • Amazon CloudSearch API Reference
    • AWS Data Exchange
      • Common
        • Security
      • Topics
        • Subscribing to data products
        • Providing data products
        • AWS Marketplace Catalog API
    • AWS Data Pipeline
      • Common
        • Troubleshooting
      • Topics
        • AWS Data Pipeline Concepts
        • Working with Pipelines
        • Pipeline Expressions and Functions
        • Pipeline Object Reference
        • Working with Task Runner
    • Amazon OpenSearch Service
      • Common
        • Getting started
        • Monitoring domains
        • Security
        • Monitoring data
        • Tutorials
      • Topics
        • Amazon OpenSearch Serverless
        • Amazon OpenSearch Ingestion
        • Creating and managing domains
        • Sample code
        • Indexing data
        • Searching data
        • Managing indexes
        • Best practices
        • General reference
    • AWS Glue
      • Common
        • Getting started
      • Topics
        • How it works
        • Data Catalog and crawlers
        • Job development (interactive sessions)
        • ETL jobs
        • Orchestration
        • AWS Glue API
        • Troubleshooting AWS Glue
    • Amazon MSK
      • Common
        • Getting started
        • Security
        • Monitoring a cluster
      • Topics
        • How it works
        • Configuration
        • MSK Connect
        • Connecting to an MSK cluster
        • Apache Kafka versions
  • Robotics
    • AWS RoboMaker
      • Common
        • Security
      • Topics
  • Blockchain
    • Amazon Managed Blockchain
      • Common
        • Getting Started
      • Topics
        • Work with Hyperledger Fabric
  • Game Development
    • Amazon GameLift
      • Common
      • Topics
        • Setting up
        • Preparing games for Amazon GameLift
        • Managing hosting resources
        • Viewing game data
Powered by GitBook
On this page
  • Create a Step Functions state machine that uses Lambda
  • Handling Error Conditions Using a State Machine
  • Starting a State Machine Execution in Response to Amazon S3 Events
  • Creating a Step Functions API Using API Gateway
  • Creating an Activity State Machine
  • Iterating a Loop Using Lambda
  • Continuing Ongoing Work as a New Execution
  • Using Code Snippets
  • Deploying an Example Human Approval Project
  • View X-Ray traces in Step Functions

Was this helpful?

Edit on GitHub
  1. Application Integration
  2. AWS Step Functions
  3. Common

Tutorials

PreviousCommonNextWorking with other services

Last updated 1 year ago

Was this helpful?

This page was generated from content adapted from the

Create a Step Functions state machine that uses Lambda

  • Note In Step Functions, a workflow is called a state machine, which is a series of event-driven steps. Each step in a workflow is called a state. A Task state represents a unit of work that another AWS service, such as AWS Lambda, performs. A Task state can call any AWS service or API. For more information, see:

  • Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.

  • Note You can also pass payloads while invoking Lambda from a state machine. For more information and examples about invoking Lambda by passing payload in the Parameters field, see .

Handling Error Conditions Using a State Machine

  • Note You can also create state machines that Retry on timeouts or those that use Catch to transition to a specific state when an error or timeout occurs. For examples of these error handling techniques, see .

  • Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.

Starting a State Machine Execution in Response to Amazon S3 Events

  • Note You must configure EventBridge rule in the same AWS Region as the Amazon S3 bucket.

Creating a Step Functions API Using API Gateway

  • Note Although Amazon API Gateway can start a Step Functions execution by calling [StartExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html), you must call [DescribeExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_DescribeExecution.html) to get the result.

  • Note For more information, see the StartExecution in the AWS Step Functions API Reference. If you don't want to include the ARN of your state machine in the body of your API Gateway call, you can configure a body-mapping template, as shown in the following example.

  • Note You can view the execution by choosing your state machine on the .

Creating an Activity State Machine

  • Important Ensure that your activity task is under the same AWS account as your state machine.

Iterating a Loop Using Lambda

  • Note If you set index to 9 for this test, the index increments to 10, and continue is false.

Continuing Ongoing Work as a New Execution

  • Note If you set index to 9 for this test, the index increments to 10, and continue is false.

  • Note Save the Amazon Resource Name (ARN) of this state machine.

  • Note You can update the "Resource": "*" line in the previous example to reference the ARN of your ContinueAsNew state machine. This restricts the policy so that it can only start an execution of that specific state machine.

Using Code Snippets

Deploying an Example Human Approval Project

  • Note You will need to provide a valid email address that you have access to when you create the AWS CloudFormation stack.

View X-Ray traces in Step Functions

  • Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.

Note For a more complete example of an activity worker, see . This example provides an implementation based on best practices, which you can use as a reference for your activity worker. The code implements a consumer-producer pattern with a configurable number of threads for pollers and activity workers.

Note The EnvironmentVariableCredentialsProvider class in this example assumes that the AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY) environment variables are set. For more information about providing the required credentials to the factory, see in the AWS SDK for Java API Reference and in the AWS SDK for Java Developer Guide. By default the AWS SDK will wait up to 50 seconds to receive data from the server for any operation. The GetActivityTask operation is a long-poll operation that will wait up to 60 seconds for the next available task. To prevent receiving a SocketTimeoutException error, set SocketTimeout to 70 seconds.

Note If you have completed the tutorial, you can skip this step and use that Lambda function.

Note Under the Task state options section, you can also configure Retry, Catch, and TimeoutSeconds options. See .

AWS Developer Guide
What is AWS Step Functions?
Call other AWS services
Invoke Lambda with Step Functions
Examples Using Retry and Using Catch
Request Syntax
AWS Step Functions console
Example Activity Worker in Ruby
AWSCredentialsProvider
Set Up AWS Credentials and Region for Development
Iterating a Loop Using Lambda
Error handling in Step Functions