4

我有一个 step 函数,它应该调用 API Gateway 资源而不是 lambda。这样做的语法是什么?

{"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": [
     ....]
}
}

我的问题是,是否可以在资源中调用 API 网关而不是“some-lamda”

4

2 回答 2

7

不,这是不可能的。

您必须使用 Lambda 函数来调用 API Gateway。

于 2017-03-30T20:00:50.353 回答
1

2020 年 11 月 17 日发布的更新使从 Step Functions 调用 API Gateway 资源成为可能。

在上面的定义中,some-lambda如果 API Gateway 资源被调用,那么定义将如下所示:

{
    "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": []
    }
}

文档 说明:注意不允许的标头

例子

于 2020-12-05T12:40:34.467 回答