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.
To learn about integrating with AWS services in Step Functions, see Integrating services and Passing parameters to a service API in Step Functions.
Key features of Optimized Amazon SQS integration
There are no optimizations for the Request Response or Wait for a Callback with Task Token integration patterns.
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: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 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.
Supported Amazon SQS APIs
-
Supported parameters:
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
.
Note
There is a quota for the maximum input or result data size for a task in Step Functions. This restricts you to 256 KiB 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.
IAM policies for calling Amazon SQS
The following example templates show how AWS Step Functions generates IAM policies based on the resources in your state machine definition. For more information, see How Step Functions generates IAM policies for integrated services and Discover service integration patterns in Step Functions.
Static resources
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:SendMessage"
],
"Resource": [
"arn:aws:sqs:[[region]]
:[[accountId]]
:[[queueName]]
"
]
}
]
}
Dynamic resources
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:SendMessage"
],
"Resource": "*"
}
]
}