如何在 CloudFormation 模板中同时使用 Sub 和 GetAtt 函数? [英] How to use Sub and GetAtt functions at the same time in CloudFormation template?

查看:32
本文介绍了如何在 CloudFormation 模板中同时使用 Sub 和 GetAtt 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了 CloudFormation yaml 模板,我需要在AWS::ApiGateway::"中使用 !GetAttTestLambda.Arn" 作为 !Sub 函数的一部分方法"集成 Uri:

I created CloudFormation yaml template and I need to use !GetAtt "TestLambda.Arn" as part of !Sub function in "AWS::ApiGateway::Method" Integration Uri:

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"

结果我想得到一个类似的值:

As result I want to get a value something like that:

"arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/my-endpoint-lambda/invocations"

如何一起使用这些函数并获得想要的结果?

How can I use these functions together and get the desired result?

推荐答案

如果先使用 ! 缩写形式,我们可以将 Fn:: 用于嵌套的内部函数.所以

We can use Fn:: for the nested intrinsic functions if using the ! short form first. So

!Sub "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/$(Fn::GetAtt:[TestLambda, Arn])/invocations"

这篇关于如何在 CloudFormation 模板中同时使用 Sub 和 GetAtt 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆