I have a step function which should call an API Gateway resource instead of a lambda. What is the syntax to do that ?
{"Comment": "A Hello World example of the Amazon States Language using a Pass state",
"StartAt": "QueueProducts",
"States": {
"GetProductsFromDb": {
"Type": "Task",
"Resource":"some-lambda",
"Next": "InvokeAPIGatewayWorkers"
}
},
"InvokeAPIGatewayWorkers":{
"Type": "Parallel",
"Branches": [
....]
}
}
My question is, Is it possible to invoke an API Gateway in the Resource instead of "some-lamda"
No, this is not possible.
You would have to use a Lambda function to make the call to API Gateway.
Updates released on 17/11/2020 has made it possible to call API Gateway resource from Step Functions.
In above definition, instead of some-lambda
if API Gateway resource is called then definition will look like this :
{
"Comment": "An example of calling an API Gateway Resouce from one of the states of Step Function",
"StartAt": "QueueProducts",
"States": {
"GetProductsFromDb": {
"Type": "Task",
"Resource": "arn:aws:states:::apigateway:invoke",
"Parameters": {
"ApiEndpoint": "{{api_gateway_id}}.execute-api.{{aws_region}}.amazonaws.com",
"Method": "GET",
"Headers": {
"session_id.$": "States.Array($.token)"
},
"Stage": "prod",
"Path": "products",
"QueryParameters": {
"category.$": "States.Array($.category)"
}
},
"ResultSelector": {
"ProductList.$": "$.ResponseBody"
},
"Next": "InvokeAPIGatewayWorkers"
}
},
"InvokeAPIGatewayWorkers": {
"Type": "Parallel",
"Branches": []
}
}
Documentation Note : Pay attention to not permitted headers
Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With