Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the bucket url of Cloudformation template

I have a set of yaml templates (one root template and several childs) to create a root stack and nested stacks in the top level of an S3 bucket. It looks like:

my-cf-templates-bucket (S3 bucket)
├ root.yaml
├ child1.yaml
├ child2.yaml
├ ...
└ childN.yaml

In order to supply the TemplateURL of the child templates, currently I make use of a parameter TemplateS3Bucket for the bucket URL:

Parameters:
  TemplateS3Bucket:
    Description: The bucket url for templates
    Type: String
    Default: https://s3.eu-central-1.amazonaws.com/my-cf-templates-bucket
Resources:
  ChildStack1:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Join ["/", [ !Ref TemplateS3Bucket, "child1.yaml"]]
      Parameters:
        ProjectName: !Ref ProjectName
  ChildStack1:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Join ["/", [ !Ref TemplateS3Bucket, "child2.yaml"]]
      Parameters:
        ProjectName: !Ref ProjectName
  # ...
  ChildStackN:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Join ["/", [ !Ref TemplateS3Bucket, "childN.yaml"]]
      Parameters:
        ProjectName: !Ref ProjectName

The question is:

Is there a way (!GetAtt etc.) to get the bucket URL of the S3 root template through which I create a stack in AWS CloudFormation console (not aws-cli).

Having such a way, I could intrinsically have the bucket url for the child templates and neither need to add them as overrideable parameters nor repeat the full bucket url for all the templateURL properties of the child stacks.

like image 310
vahdet Avatar asked Dec 10 '25 22:12

vahdet


1 Answers

No way that I'm aware of. Passing the S3 bucket of the templates as a parameters seems to be the the standard/most common way of doing things.

like image 93
sharingan Avatar answered Dec 12 '25 15:12

sharingan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!