在yaml中的Cloudformation嵌套堆栈输出

Jep*_*ppz 3 yaml amazon-web-services aws-cloudformation

在我的嵌套堆栈中,我需要使用输出值,AWS :: CloudFormation :: Stack返回值为

Fn :: GetAtt Outputs.NestedStackOutputName

但是yaml不允许我使用

!GetAtt MyResourceName.Outputs.MyOutputName
Run Code Online (Sandbox Code Playgroud)

因为它试图将它们分成3块而不是它需要的2块.

我也试过用

Value: "Fn::GetAtt": [ "MyResourceName", "Outputs.MyOutputName" ] 
Run Code Online (Sandbox Code Playgroud)

但后来我明白了

mapping values are not allowed here
  in "<string>", line 21, column 24:
        Value: "Fn::GetAtt": [ "MyResourceName", "Outputs.MyOutputName" ]
Run Code Online (Sandbox Code Playgroud)

那我该怎么用?我真的必须切换到json吗?

spg*_*spg 9

它使用这两个堆栈对我有用:

root.yml:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyNestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://s3.amazonaws.com/spg-test-bucket/cloudformation/nested.yml?versionId=HqlgDnuntMzkmK0398GPdJRUXMN_PMdn
  RootBucket:
    Type: AWS::S3::Bucket
    Properties:
      LoggingConfiguration:
        DestinationBucketName:
          Fn::GetAtt: [MyNestedStack, Outputs.NestedBucket]
Run Code Online (Sandbox Code Playgroud)

nested.yml:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  DataBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: LogDeliveryWrite
Outputs:
  NestedBucket:
    Value:
      Ref: DataBucket
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,这有效。语法方面确实缺少AWS文档。 (2认同)

wjo*_*dan 4

您的问题是由于 的自定义YAML 解析代码中的一个已知错误造成的,该代码最近作为和的一部分添加aws-cliaws cloudformation deployaws cloudformation package

该问题已在1.11.37 版本中修复aws-cli。要解决此问题,您可以执行以下任一操作:

  • 升级aws-cli到版本 1.11.37 或更高版本。
  • 如果您不使用本地工件,请使用aws cloudformation [create|update]-stack创建/更新您的堆栈而不是。aws cloudformation [package|deploy]