CloudFormation Nested Stacks

CloudFormation Nested Stacks

  • Create stacks within other stacks
  • Nested Stacks allow re-use of CloudFormation code for common use cases
  • e.g. standard configuration for a load balancer, web server, application server etc
  • Instead of copying out the code each time, create a standard template for each common use case and reference from within your CloudFormation template
  • create dedicated template for load balancer and store it in its own cloud formation template
    • reference it from within another cloud formation template

CloudFormation Template Structure

Resources:
    Type: AWS::CloudFormation::Stack
    Properties:
        NotificationARNs:
            -String
        Parameters:
            AWS CloudFormation Stack Parameters
        Tags:
            -Resource Tag
        TemplateURL: https://s3.amazonaws.com/.../template.yml
        TimeoutInMinutes: Integer
  • template URL is mandatory
  • must be a file located in S3 bucket
  • default is no timeout, timeout is optional

CloudFormation Nested Stacks - Exam Tips

  • Nested Stacks allow you to re-use your CloudFormation code so you don't need to copy/paste every time
  • Really useful for frequently used configurations, e.g. for load balancers, web or application servers
  • Simply create a CloudFormation template, store it in S3, and you can reference it in the Resources section of any CloudFormation template using the Stack resource type