Starting the execution of the Step Function State Machine via AWS Console to call the SQS SendMessage
API from a Task state. The State Machine accepts values in a JSON format (please see sample payload) and will execute the SQS SendMessage
API to send a message to the configured SQS Queue, and the Lambda Function will process the received event from the Amazon SQS event message.
{
"StartAt": "transaction-definition",
"States": {
"transaction-definition": {
"End": true,
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage",
"Parameters": {
"QueueUrl": "https://sqs.us-east-1.amazonaws.com/123456789101/transaction-queue.fifo",
"MessageBody": {
"id.$": "$.id",
"order_line_id.$": "$.line_id",
"total.$": "$.total",
"change.$": "$.change",
"customer.$": "$.customer"
},
"MessageGroupId": "process.transaction"
}
}
}
}
{
"id": "transaction-12345",
"line_id": "line-12345",
"total": 250.50,
"change": 249.50,
"customer": {
"id": "customer-12345",
"name": "John Doe"
}
}
{
"log_code": "SQSMessage",
"log_msg": "recieved event from Amazon SQS",
"log_level": "INFO",
"log_keys": {
"transaction": {
"id": "transaction-12345",
"order_line_id": "line-12345",
"customer": {
"id": "customer-12345",
"name": "John Doe"
},
"total": 250.5,
"change": 249.5
}
},
"log_timestamp": "2023-05-17 05:51:23"
}
- AWS Lambda
- AWS Step Functions
- Tasks for Steps Functions
- Amazon CloudWatch Logs
- AWS Lambda Event Sources
- Amazon Simple Queue Service
- States
- Amazon States Language
- AWS Step Function Guides
- Amazon SQS dead-letter queues
- Amazon SQS visibility timeout
- Call Amazon SQS with Step Functions
- Amazon SQS FIFO (First-In-First-Out) queues
- Input and Output Processing in Step Functions
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sqs$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sqs$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sqs$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sqs$ make deploy profile=[profile_name]