Nested stacks in CloudFormation or SAM has tree-like structure. Usually,
there is a root stack, which contains multiple other stacks, aka nested
stacks.
Nested stacks can have other nested stacks, creating hierarchy of stacks.
Stack update operation happens at the root level, so if you need to have
seperate deployable stacks, consider using SSM parameters. Using SSM
parameters, you can deploy different stacks without intitating root-level
stack update, and sharing of data between happens using SSM parameters. For
example, Stack A deploys kms and s3 resources and saves the id or arn of kms
or s3 bucket to SSM parameters. Stack B deploy DynamoDB and Lambda
functions. Stack B reads from SSM parameters that was saved by Stack A, and
uses the ids or Arns to maybe use encryption key.
For SAM users, make sure to add "Transform: AWS::Serverless-2016-10-31" to
root.yml. In terms of resources type in root.yml,
"AWS::Serverless::Application" macro is optional for SAM since it would
understand "AWS::Cloudformation::Stack" type as well. We have added #
comments to make it easy for you copy and understand the subtles changes for
SAM
Let's dive into the code showing how to use SAM or CloudFormation nested
stacks and share parameters or variables with child Stacks