【问题标题】:How can I create a AWS APIGateway Custom Authorizer using stage variables in Terraform?如何使用 Terraform 中的阶段变量创建 AWS APIGateway 自定义授权方?
【发布时间】:2018-06-12 17:50:19
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: amazon-web-services aws-api-gateway terraform api-gateway


    【解决方案1】:

    您实际上可以通过 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"
      ...
    }
    

    【讨论】:

    • 这很有趣。如果您愿意这样做,可能值得提出pull request 来更新文档?
    • 谢谢 - 在写这篇文章之前,我在 Github 上寻找过文档,但找不到。提出公关。
    猜你喜欢
    • 2017-12-13
    • 2022-08-11
    • 2017-05-20
    • 2022-12-04
    • 2017-05-31
    • 1970-01-01
    • 2017-07-02
    • 2021-08-14
    • 2016-11-23
    相关资源
    最近更新 更多