我正在尝试部署使用terraform的自定义授权程序的API Gateway REST API .
自定义授权程序使用现有的lambda函数 .
resource "aws_api_gateway_authorizer" "accountprofileauth" {
name = "auth"
rest_api_id = "${aws_api_gateway_rest_api.accountprofileapi.id}"
authorizer_uri = "arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer"
identity_source = "method.request.header.Authorization"
type = "REQUEST"
}
当我做terraform apply时,我得到了以下错误
* aws_api_gateway_authorizer.accountprofileauth: Error creating API Gateway Authorizer: BadRequestException: Invalid Authorizer URI: arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer. Authorizer URI should be a valid API Gateway ARN that represents a Lambda function invocation.
status code: 400, request id: XXXX
lambda函数存在,它工作正常 . 使用无服务器进行部署时,同样的arn工作正常 .
你知道格式/提供有效arn的例子吗?
谢谢 .
2 回答
我找到了实际的格式
看起来日期有点硬编码 . 我很困惑:)
您可以参考AWS文档Amazon Resource Names (ARNs) and AWS Service Namespaces
对于lambda
AWS Lambda(Lambda)
例子:
如果您也在terraform中创建labmda函数(不是在您的情况下,但我建议管理terraform中的所有aws资源,如果您已经开始使用它)
您可以轻松地将lambda arn引用为
authorizer_uri