According to Amazon\'s documentation, step function can be invoked using HTTP API.
Step Functions can be accessed and used with the Step Functions c
It's using HTTP API, not API Gateway.
Step function endpoints follow this format:
https://states.${region}.amazonaws.com
for example:
https://states.us-east-1.amazonaws.com
And you use HTTP API (again, not API gateway) to make actions on your states.
More about HTTP API here:
http://docs.aws.amazon.com/step-functions/latest/apireference/Welcome.html
Technically you could use API gateway, to redirect to step functions API but there's not much point in that.
This is not the "official" AWS way -- see Erndob's answer for that.
The problem with the AWS way (sign each request with AWS credentials) is that most enterprises already have mature methods in place to manage authentication and authorization via their API gateways and (speaking as an enterpise architect) do not want to deal with the headache of duplicating this at the AWS-credential-level.
I'm sure that AWS will eventually integrate Step Functions with API Gateway but as of this writing (1/17) this is probably the simplest way to get the job done. Below is a trivial Lambda proxy function I wrote to leverage the SDK's ability to sign the requests:
'use strict';
const AWS = require('aws-sdk');
const stepfunctions = new AWS.StepFunctions();
exports.handler = (event, context, callback) => {
if(!event && event.action)
callback("Error: 'action' is required.");
if(!event && event.params)
callback("Error: 'params' is required.");
stepfunctions[event.action](event.params, function (err, data) {
if (err)
console.log(err, err.stack);
callback(err, data);
});
};
You will need to grant your Lambda privs to interact with your Step Functions. To give it full access to all operations create a new role and attach the following policies:
Now configure the Lambda to be invoked via API gateway as normal, passing in an event with two properties:
And be sure to lock your API down! :-)
I recently posted an example code that make it work using CloudFormation and OpenApi on https://stackoverflow.com/a/59326771/6697093.
If you need to call StepFunction from API Gateway, it's now possible and described well in docs: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-api-gateway.html
AWS Service
Step Functions
from the listPOST
from the listUse action name
StartExecution
API Gateway
trusted identity provider and attached policy AWSStepFunctionsFullAccess