[英]How to pass AWS AccountId in REST API's uri(Cloudformation)
Code:代码:
x-amazon-apigateway-integration:
uri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:428377611111:function:${stageVariables.target_lambdaName}/invocations"
If use Pseudo Parameters like below i'm facing issue.如果使用如下伪参数,我将面临问题。
Updated Code:更新代码:
x-amazon-apigateway-integration:
uri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:${AWS::AccountId}:function:${stageVariables.target_lambdaName}/invocations"
Errors found during import: Unable to put integration on 'GET' for resource at path '/getMessage': Invalid HTTP endpoint specified for URI (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 3da76bd8-d714-11e8-8ec4-4b324c6636a4)
Thanks in advance.提前致谢。
Naresh纳雷什
First, you should remove your AWS Account ID from the question.首先,您应该从问题中删除您的 AWS 账户 ID。
If you're using a SAM Template YAML file and passing variables to your template during your pipeline stage via ParameterOverrides you should then have parameters declared at the top of the file in your SAM Template YAML file and your code should be as an example POST.如果您使用的是 SAM 模板 YAML 文件并在管道阶段通过 ParameterOverrides 将变量传递给模板,那么您应该在 SAM 模板 YAML 文件的文件顶部声明参数,并且您的代码应该作为示例 POST。
paths:
/PATH_NAME:
get:
responses: {}
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FUNCTION_NAME_HERE.Arn}/invocations
httpMethod: POST
type: aws_proxy
This is assuming this piece of code is attached to:这是假设这段代码附加到:
Type: AWS::Serverless::Api
Without any other information I'm just assuming what you're trying to do.没有任何其他信息,我只是假设您要做什么。
As a side note, you can access your account id in CloudFormation like so:作为旁注,您可以在 CloudFormation 中访问您的帐户 ID,如下所示:
${AWS::AccountId}
Use of Pseudo Parameters in the SAM AWS::Serverless::Api resource has been documented in this realworld SAM example Github https://github.com/awslabs/realworld-serverless-application/wiki/Amazon-API-Gateway#use-awsserverlessapi-in-your-cloudformation-template在这个真实世界的 SAM 示例 Github https://github.com/awslabs/realworld-serverless-application/wiki/Amazon-API-Gateway#use- 中记录了在 SAM AWS::Serverless::Api 资源中使用伪参数awsserverlessapi-in-your-cloudformation-template
The example using AWS::Include allows the use of Pseudo Parameters in the swagger file.使用AWS::Include的示例允许在 swagger 文件中使用伪参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.