0

我看到 AWS ApiGateway 现在提供了将阶段变量传递给控制台中的自定义授权 lambda 的能力,方法是选择“请求”类型的有效负载并列出应该传递的变量。

但是,我们仅通过 Terraform 创建我们的 AWS 资源(不允许手动干预),Terraform 文档目前说:

type - (Optional) The type of the authorizer. TOKEN is currently the only allowed value. Defaults to TOKEN.

有没有办法以编程方式强制有效负载类型为“请求”,并传入阶段变量?

4

1 回答 1

4

你实际上可以通过 Terraform 做到这一点,不管文档怎么说。

只需将类型设置为 REQUEST,并在逗号分隔的列表中传递阶段变量(和/或标题,和/或查询字符串),如下所示:“method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName, stageVariables.SomeStageVariableName”等:

resource "aws_api_gateway_authorizer" "api-gateway-auth" {
  ...
  type            = "REQUEST"
  identity_source = "method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"
  ...
}
于 2018-01-03T03:43:41.823 回答