Created
May 16, 2017 05:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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