【问题标题】:Enable Provisioned Concurrency for a Lambda Authorizer为 Lambda 授权方启用预置并发
【发布时间】:2021-06-07 15:33:00
【问题描述】:

使用 Terraform,我有一个 AWS HTTP API 网关的配置,如下所示:

resource "aws_apigatewayv2_authorizer" "authorizer" {
  api_id = module.api_gateway.this_apigatewayv2_api_id
  name   = "authorizer"
  authorizer_payload_format_version = "2.0"
  enable_simple_responses           = true
  authorizer_result_ttl_in_seconds  = var.authorizer_result_ttl_in_seconds
  authorizer_type  = "REQUEST"
  identity_sources = ["$request.header.Authorization"]
 
  # Problem is below:
  authorizer_uri = module.auth-authorizer-lambda.this_lambda_function_invoke_arn
}

当我使用this_lambda_function_invoke_arn 时,这可以正常工作,但不会调用 Lambda 的并发配置版本(因此 Lambda 可以工作,例如 4s)。通常可以通过this_lambda_function_qualified_arn 引用这样的版本,但使用它会导致错误:

Error: error updating API Gateway v2 authorizer: BadRequestException: Invalid Authorizer URI:
arn:aws:lambda:eu-west-1:<account-id>:function:authorizer:5. 
Authorizer URI should be a valid API Gateway ARN that represents a Lambda function invocation.

如何配置 API 网关以使用特定版本的 Authorizer lambda?

【问题讨论】:

    标签: amazon-web-services aws-lambda terraform terraform-provider-aws


    【解决方案1】:

    没有显示auth-authorizer-lambda模块是什么,但是this_lambda_function_invoke_arn的使用是错误的。 authorizer_uri 的正确形式如following example 所示:

    arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
    

    因此您必须以如上所示的形式构造并提供authorizer_uri。显然,它必须根据您的区域、帐户 id 和函数名称进行调整。

    【讨论】:

      猜你喜欢
      • 2022-08-24
      • 2017-11-12
      • 2020-10-24
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多