Skip to content

Instantly share code, notes, and snippets.

@byrro
Last active August 18, 2020 16:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save byrro/93ddb063ee42a9c083d507723d77a971 to your computer and use it in GitHub Desktop.
Save byrro/93ddb063ee42a9c083d507723d77a971 to your computer and use it in GitHub Desktop.
AWS Step Functions Example - Data Migration
{
"Comment" : "An example of the Amazon States Language for reading messages from a DynamoDB table and sending them to SQS",
"StartAt": "Seed the DynamoDB Table",
"TimeoutSeconds": 3600,
"States": {
"Seed the DynamoDB Table": {
"Type": "Task",
"Resource": "<SEEDING_LAMBDA_FUNCTION_ARN>",
"ResultPath": "$.List",
"Next": "For Loop Condition"
},
"For Loop Condition": {
"Type": "Choice",
"Choices": [
{
"Not": {
"Variable": "$.List[0]",
"StringEquals": "DONE"
},
"Next": "Read Next Message from DynamoDB"
}
],
"Default": "Succeed"
},
"Read Next Message from DynamoDB": {
"Type": "Task",
"Resource": "arn:<PARTITION>:states:::dynamodb:getItem",
"Parameters": {
"TableName": "<DYNAMO_DB_TABLE_NAME>",
"Key": {
"MessageId": {"S.$": "$.List[0]"}
}
},
"ResultPath": "$.DynamoDB",
"Next": "Send Message to SQS"
},
"Send Message to SQS": {
"Type": "Task",
"Resource": "arn:<PARTITION>:states:::sqs:sendMessage",
"Parameters": {
"MessageBody.$": "$.DynamoDB.Item.Message.S",
"QueueUrl": "<SQS_QUEUE_URL>"
},
"ResultPath": "$.SQS",
"Next": "Pop Element from List"
},
"Pop Element from List": {
"Type": "Pass",
"Parameters": {
"List.$": "$.List[1:]"
},
"Next": "For Loop Condition"
},
"Succeed": {
"Type": "Succeed"
}
}
}

CREDITS

This code snippet was extracted from an AWS Step Functions example.

It can ben found in the AWS Console for the Step Functions service.

Follow the instructions on this documentation page

Date: 2019-10-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment