💾 Archived View for cfdocs.wetterberg.nu › using-cfn-nested-stacks.gemini captured on 2024-05-12 at 15:28:39. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Working with nested stacks

Search

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html

As your infrastructure grows, common patterns can emerge in which you declare the same components in multiple templates. You can separate out these common components and create dedicated templates for them. Then use the resource in your template to reference other templates, creating nested stacks.

For example, assume that you have a load balancer configuration that you use for most of your stacks. Instead of copying and pasting the same configurations into your templates, you can create a dedicated template for the load balancer. Then, you just use the resource to reference that template from within other templates.

Nested stacks can themselves contain other nested stacks, resulting in a hierarchy of stacks, as in the diagram below. The *root stack* is the top-level stack to which all the nested stacks ultimately belong. In addition, each nested stack has an immediate *parent stack*. For the first level of nested stacks, the root stack is also the parent stack. in the diagram below, for example:

{P Image}

Using nested stacks to declare common components is considered a best practice.

best practice

Certain stack operations, such as stack updates, should be initiated from the root stack rather than performed directly on nested stacks themselves. Also, in some cases, nested stacks affect how stack operations are performed. For more information, refer to the following topics:

Use nested stacks to reuse common template patterns

Protecting a stack from being deleted

Update behaviors of stack resources

Exporting stack output values vs. using nested stacks

Using ResourcesToSkip to recover a nested stacks hierarchy

Nested stacks are stuck in UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, or UPDATE_ROLLBACK_IN_PROGRESS

https://console.aws.amazon.com/cloudformation/

https://console.aws.amazon.com/cloudformation/

Change sets for nested stacks

Nesting an existing stack