Send messages to an Amazon SQS queue with Step Functions - 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).

Send messages to an Amazon SQS queue with Step Functions

Learn how to use Step Functions to send messages to an Amazon SQS queue. This page lists the supported Amazon SQS API actions and provides example Task states to send messages to a queue.

Step Functions can control certain Amazon services directly from Using Amazon States Language to define Step Functions workflows (ASL). To learn more, see Integrating other services and Passing parameters to a service API in Step Functions.

How the Optimized Amazon SQS integration is different than the Amazon SQS Amazon SDK integration

There are no optimizations for the Request Response or Wait for a Callback with the Task Token integration patterns.

Supported Amazon SQS APIs:

Note

There is a quota for the maximum input or result data size for a task in Step Functions. This restricts you to 256 KB of data as a UTF-8 encoded string when you send to, or receive data from, another service. See Quotas related to state machine executions.

Parameters in Step Functions are expressed in PascalCase

Even if the native service API is in camelCase, for example the API action startSyncExecution, you specify parameters in PascalCase, such as: StateMachineArn.

The following includes a Task state that sends an Amazon Simple Queue Service (Amazon SQS) message.

{ "StartAt": "Send to SQS", "States": { "Send to SQS": { "Type": "Task", "Resource": "arn:aws-cn:states:::sqs:sendMessage", "Parameters": { "QueueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/myQueue", "MessageBody.$": "$.input.message", "MessageAttributes": { "my_attribute_no_1": { "DataType": "String", "StringValue": "attribute1" }, "my_attribute_no_2": { "DataType": "String", "StringValue": "attribute2" } } }, "End": true } } }

The following includes a Task state that publishes to an Amazon SQS queue, and then waits for the task token to be returned. See Wait for a Callback with the Task Token.

{ "StartAt":"Send message to SQS", "States":{ "Send message to SQS":{ "Type":"Task", "Resource":"arn:aws:states:::sqs:sendMessage.waitForTaskToken", "Parameters":{ "QueueUrl":"https://sqs.us-east-1.amazonaws.com/123456789012/myQueue", "MessageBody":{ "Input.$":"$", "TaskToken.$":"$$.Task.Token" } }, "End":true } } }

To learn more about receiving messages in Amazon SQS, see Receive and Delete Your Message in the Amazon Simple Queue Service Developer Guide.

For information about how to configure IAM permissions when using Step Functions with other Amazon services, see How Step Functions generates IAM policies for integrated services.