【发布时间】:2017-05-02 11:56:26
【问题描述】:
我想知道如何让 API Gateway 调用 Step Function 并执行它。
【问题讨论】:
-
我认为这个问题比其他问题更有价值,因为有一个关于如何从 api 网关创建 aws sf 调用的解释
标签: amazon-web-services aws-api-gateway aws-step-functions
我想知道如何让 API Gateway 调用 Step Function 并执行它。
【问题讨论】:
标签: amazon-web-services aws-api-gateway aws-step-functions
API Gateway 目前添加了对 Step Functions 的支持。现在您可以通过 API Gateway 控制台创建 AWS 服务集成。
标题:
X-Amz-Target -> 'AWSStepFunctions.StartExecution'
内容类型 -> 'application/x-amz-json-1.0'
正文映射模板/请求负载:
{ “输入”:“字符串”, “名称”:“字符串”, “stateMachineArn”:“字符串” }
【讨论】:
stateMachineArn 中定义的 ARN 不是无效的。你能验证一下吗?
您可以使用Integration type: AWS Service 创建一个 API Gateway Endpoint,并将其设置为调用所需的 Step Function。
如果您想使用 API Gateway 来控制 Step Functions 端点的公开,您可以使用仅授予访问权限的策略创建一个新的 IAM 用户(仅限编程访问)到这个端点,例如:
{
"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"
]
}
]
}
【讨论】:
我认为您可以使用 API Gateway 代理集成到 AWS 服务。看:https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-console.html
【讨论】:
考虑创建一个支持 APIGw 端点的 AWS Lambda 函数,并让它通过代码调用 AWS StepFunctions。我们使用这种方法是因为我们的用例允许 API 端点参数指示我们需要执行几个 StepFunction 中的哪一个。
诚然,这是“更多代码”;我们希望 AWS 详细说明 StepFunction,以便它们可以由整个 AWS 资源事件主机触发。
【讨论】: