I would like to know how to make API Gateway call a Step Function and execute it.
-
1duplicate: stackoverflow.com/questions/41113666/…Brandon– Brandon2016-12-26 19:11:16 +00:00Commented Dec 26, 2016 at 19:11
-
I think this question is more valuable than others because there is a explanation about how to create a aws sf invocation from api gatewayomalave– omalave2017-03-06 15:55:44 +00:00Commented Mar 6, 2017 at 15:55
-
Possible duplicate of How to Invoke AWS step function using API gateway?Shamal Perera– Shamal Perera2017-07-12 16:40:42 +00:00Commented Jul 12, 2017 at 16:40
4 Answers
API Gateway added support for Step Functions currently. Now you can create an AWS Service integration via API Gateway Console.
- Integration Type: AWS Service
- AWS Service: Step Functions
- HTTP method: POST
- Action Type: Use action name
- Action: StartExecution
- Execution role: role to start the execution
Headers:
X-Amz-Target -> 'AWSStepFunctions.StartExecution'
Content-Type -> 'application/x-amz-json-1.0'Body Mapping Templates/Request payload:
{ "input": "string", "name": "string", "stateMachineArn": "string" }
6 Comments
stateMachineArn is not invalid. Can you verify that?You can create an API Gateway Endpoint with Integration type: AWS Service and set it up to invoke the required Step Function.
In case you want to use API Gateway so that you can control the exposure of your Step Functions endpoint, you can create a new IAM user (programmatic access only) with a policy that only grants access to this endpoint, eg:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"arn:aws:execute-api:us-east-1:my-aws-account-id:my-api-id/my-stage/GET/my-resource-path"
]
}
]
}
3 Comments
Consider creating an AWS Lambda function that backs the APIGw endpoint and having it call AWS StepFunctions via code. We use this approach because our use case allows the API endpoint parameters to direct which of several StepFunctions we need to execute.
Admittedly, it is "more code"; we're hoping AWS elaborates StepFunctions such that they can be triggered by the whole host of AWS resource events.
Comments
I think you can use API Gateway Proxy Integration to AWS service. Look: https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-console.html