Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DynamoDB table iteration with a StepFunction
{
"StartAt": "Add empty LastEvaluatedKey",
"States": {
"Add empty LastEvaluatedKey": {
"Type": "Pass",
"Next": "Scan",
"Result": {
"LastEvaluatedKey": null
},
"ResultPath": "$"
},
"Scan": {
"Type": "Task",
"Next": "Map",
"Parameters": {
"TableName": "",
"ProjectionExpression": "#id",
"ExpressionAttributeNames": {
"#id": "id"
},
"ExclusiveStartKey.$": "$.LastEvaluatedKey"
},
"Resource": "arn:aws:states:::aws-sdk:dynamodb:scan"
},
"Map": {
"Type": "Map",
"Next": "Check for more",
"Iterator": {
"StartAt": "Process",
"States": {
"Process": {
"Type": "Pass",
"End": true
}
}
},
"ItemsPath": "$.Items",
"ResultPath": null,
"MaxConcurrency": 40
},
"Check for more": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.LastEvaluatedKey",
"IsPresent": true,
"Next": "Add new LastEvaluatedKey"
}
],
"Default": "Done"
},
"Done": {
"Type": "Succeed"
},
"Add new LastEvaluatedKey": {
"Type": "Pass",
"Next": "Scan",
"Parameters": {
"LastEvaluatedKey.$": "$.LastEvaluatedKey"
},
"ResultPath": null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment