Created
March 2, 2021 10:30
-
-
Save bahrmichael/552c0e334cdfb86f3f268a570371d32c to your computer and use it in GitHub Desktop.
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
{ | |
"StartAt": "Get Page Count", | |
"States": { | |
"Get Page Count": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::apigateway:invoke", | |
"Parameters": { | |
"ApiEndpoint": "xxxxxxxxxx.execute-api.us-east-1.amazonaws.com", | |
"Method": "HEAD", | |
"Stage": "prod", | |
"Path": "/v1/markets/10000063/orders" | |
}, | |
"ResultSelector": { | |
"pages.$": "$.Headers.X-Pages[0]" | |
}, | |
"Next": "Build Iterator" | |
}, | |
"Build Iterator": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::lambda:invoke", | |
"Parameters": { | |
"FunctionName": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:RangeBuilder", | |
"Payload": { | |
"pages.$": "$.pages" | |
} | |
}, | |
"ResultSelector": { | |
"iterator.$": "$.Payload" | |
}, | |
"Next": "Fetch Pages" | |
}, | |
"Fetch Pages": { | |
"Type": "Map", | |
"ItemsPath": "$.iterator", | |
"Parameters": { | |
"page.$": "$$.Map.Item.Value" | |
}, | |
"Iterator": { | |
"StartAt": "Fetch Page", | |
"States": { | |
"Fetch Page": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::apigateway:invoke", | |
"Parameters": { | |
"ApiEndpoint": "xxxxxxxxx.execute-api.us-east-1.amazonaws.com", | |
"Method": "GET", | |
"Stage": "prod", | |
"Path": "/v1/markets/10000063/orders", | |
"QueryParameters.$": "$" | |
}, | |
"ResultSelector": { | |
"P.$": "$.ResponseBody..price", | |
"T.$": "$.ResponseBody..type_id", | |
"V.$": "$.ResponseBody..volume_remain" | |
}, | |
"End": true | |
} | |
} | |
}, | |
"Next": "Aggregate" | |
}, | |
"Aggregate": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::lambda:invoke", | |
"Parameters": { | |
"FunctionName": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:market-data-aggregate", | |
"Payload": { | |
"data.$": "$" | |
} | |
}, | |
"ResultSelector": { | |
"aggregated.$": "$.Payload" | |
}, | |
"Next": "Store Records" | |
}, | |
"Store Records": { | |
"Type": "Map", | |
"ItemsPath": "$.aggregated", | |
"Iterator": { | |
"StartAt": "Store Record", | |
"States": { | |
"Store Record": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::dynamodb:putItem", | |
"Parameters": { | |
"TableName": "MarketData", | |
"Item": { | |
"pk": { | |
"S.$": "$.k" | |
}, | |
"volume": { | |
"N.$": "States.Format($.v)" | |
}, | |
"price": { | |
"N.$": "States.Format($.p)" | |
} | |
} | |
}, | |
"End": true | |
} | |
} | |
}, | |
"End": true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment