Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation nested stack outputs in yaml

In my nested stacks I need to use output values and AWS::CloudFormation::Stack returns values as

Fn::GetAtt Outputs.NestedStackOutputName

But yaml doesn't allow me to use

!GetAtt MyResourceName.Outputs.MyOutputName

as it tries to split them into 3 pieces instead of the 2 it requires.

I also tried using

Value: "Fn::GetAtt": [ "MyResourceName", "Outputs.MyOutputName" ] 

but then I get

mapping values are not allowed here
  in "<string>", line 21, column 24:
        Value: "Fn::GetAtt": [ "MyResourceName", "Outputs.MyOutputName" ]

So how am I supposed to use this? Do I really have to switch to json for this?

like image 638
Jeppz Avatar asked Dec 04 '22 23:12

Jeppz


1 Answers

It worked for me using these 2 stacks:

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]

nested.yml:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  DataBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: LogDeliveryWrite
Outputs:
  NestedBucket:
    Value:
      Ref: DataBucket
like image 77
spg Avatar answered Dec 09 '22 15:12

spg