Skip to content

Instantly share code, notes, and snippets.

@Atrix1987
Created May 16, 2017 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Atrix1987/19f8081f20ef1f67f73bbc8b7124fe8a to your computer and use it in GitHub Desktop.
Save Atrix1987/19f8081f20ef1f67f73bbc8b7124fe8a to your computer and use it in GitHub Desktop.
A Sample state machine spec which shows wiring up lambdas execution in parallel, a choice state, a pass state, input paths and result paths
{
"Comment": "Load Data from Firebase and send it to AWS Cloud Search",
"StartAt": "CalculateInterval",
"States": {
"Get data from Firebase": {
"Type": "Parallel",
"Next": "Format Parallel Processed Data",
"Branches": [
{
"StartAt": "Fetch User Data",
"States": {
"Fetch User Data": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-west-2:12345:function:oc_fetchUserData",
"End": true
}
}
},
{
"StartAt": "Fetch Story Data",
"States": {
"Fetch Story Data": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-west-2:12345:function:oc_fetchStoryData",
"End": true
}
}
}
]
},
"Format Parallel Processed Data" :{
"Type" : "Task",
"Resource" : "arn:aws:lambda:us-west-2:12345:function:oc_convertArrayToObject",
"Next": "Check if new data found"
},
"Check if new data found" : {
"Type" : "Choice",
"Choices" : [
{
"Or" : [
{
"Variable": "$.stories.count",
"NumericGreaterThan": 0
},
{
"Variable": "$.users.count",
"NumericGreaterThan": 0
}
],
"Next" : "Add Data to Search"
}
],
"Default" : "NoDataState"
},
"Add Data to Search": {
"Type": "Task",
"Resource" : "arn:aws:lambda:us-west-2:12345:function:oc_addSearchData",
"Next" : "Cleanup",
"ResultPath" : "$"
},
"Cleanup" : {
"Type" : "Task",
"Resource" : "arn:aws:lambda:us-west-2:12345:function:oc_cleanup",
"End" : true
},
"CalculateInterval" : {
"Type" : "Task",
"Resource" : "arn:aws:lambda:us-west-2:12345:function:oc_initiateIndexing",
"Next" : "Get data from Firebase",
"ResultPath" : "$.time"
},
"NoDataState": {
"Type": "Pass",
"End" : true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment