CloudFormation テンプレートで Sub 関数と GetAtt 関数を同時に使用するにはどうすればよいでしょうか? 質問する

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"

これらの関数を一緒に使用して、目的の結果を得るにはどうすればよいですか?

ベストアンサー1

!GetAttここで使用する必要はありません!Sub。プレースホルダー内に値を配置すると、値が自動的に展開されます。

Uri: !Sub arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/${TestLambda.Arn}/invocations

これについては、ドキュメント:

などのテンプレートパラメータ名またはリソース論理 ID を指定すると、${InstanceTypeParameter}AWS CloudFormation は Ref 組み込み関数を使用した場合と同じ値を返します。 などのリソース属性を指定すると、${MyInstance.PublicIp}AWS CloudFormation は組み込み関数を使用した場合と同じ値を返しますFn::GetAtt

おすすめ記事