amazon-web-services - CloudFormation模板中如何同时使用Sub和GetAtt函数?
问题描述
我创建了 CloudFormation yaml 模板,我需要在“AWS::ApiGateway::Method”集成 Uri 中!GetAtt "TestLambda.Arn"
用作函数的一部分:!Sub
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId:
Ref: "RestApi"
ResourceId:
Ref: "TestResource"
HttpMethod: "GET"
AuthorizationType: "NONE"
Integration:
Type: "AWS_PROXY"
IntegrationHttpMethod: "POST"
Uri: !Sub "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/[[place where I want to use !GetAtt "TestLambda.Arn"]]/invocations"
结果我想得到一个类似的值:
"arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/my-endpoint-lambda/invocations"
如何将这些功能一起使用并获得所需的结果?
解决方案
您不需要在!GetAtt
这里使用,!Sub
如果您将它们放在占位符中,它将自动为您解包值:
Uri: !Sub arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/${TestLambda.Arn}/invocations
这在文档中进行了解释:
如果您指定模板参数名称或资源逻辑 ID,例如
${InstanceTypeParameter}
,AWS CloudFormation 将返回与您使用 Ref 内在函数相同的值。如果您指定资源属性,例如,AWS CloudFormation 将返回与您使用内部函数${MyInstance.PublicIp}
相同的值。Fn::GetAtt
推荐阅读
- r - dplyr 中的相对加权频率/比例
- python - 在 2D numpy 数组中加入近端段的 Pythonic 方法?
- java - Android Studio 中的按钮和活动
- google-apps-script - 如何使用脚本编辑器在谷歌表格中搜索具有相同列值的单元格?
- java - 如何根据以经纬度为界的形状确定面积?
- python-3.x - 在 Python 中构造类时如何初始化和声明 *optional* 变量?
- swift - NumberFormatter() - 可能有特定数量的空格?
- sql - 为什么我的 SQL case 表达式返回错误的结果?
- android - elements.getBoundingBox 输出是什么意思?(FirebaseVision,安卓)
- python - 解决。我们可以让 Python 决定最好的初始猜测吗?