
- a networking template (VPC, subnets, route tables),
- a compute template (Auto Scaling groups, Launch Templates), and
- an IAM template (roles, policies).


- Nested Stacks — include one stack inside another to compose hierarchical templates.
- StackSets — deploy a template consistently across multiple AWS accounts and Regions.
- Cross-Stack References — export outputs from one stack and import them into other stacks to avoid duplication.

Nested stacks
- A nested stack is a CloudFormation stack declared inside another stack. Use nested stacks to separate concerns into child stacks for networking, security, shared services, etc.
- Use nested stacks when you need tight coupling or hierarchical organization—e.g., an IAM child stack that provides roles referenced by sibling components.
- Benefits: reusability, simplified management, and logical hierarchy. Changes to a nested stack are scoped and less likely to break unrelated resources.

- StackSets let you deploy a single CloudFormation template (a StackSet) to multiple target accounts and Regions, creating stack instances in each target.
- A stack instance represents the template in a target account/Region. If creation fails in a target, the instance may be recorded without a fully created stack.
- Use StackSets for multi-account, multi-Region governance—e.g., replicate a standardized networking stack across all accounts and Regions.
- Note: StackSets require appropriate administrator permissions/roles and trust in target accounts. You can choose between the service-managed or self-managed permissions models.


- Use exports and imports to share resources across separate (non-nested) stacks. For example, a networking stack can export VPC IDs and subnet IDs; database or application stacks import those outputs rather than recreate or hard-code them.
- Benefits: reduces duplication, ensures consistency, and improves scalability. When an exported resource changes (for example, a VPC ID), importing stacks see the new value when they are created or explicitly updated — changes do not automatically propagate to existing stacks.
- Note: CloudFormation exports/imports are limited to stacks within the same AWS account and Region. To share values across accounts or Regions, use StackSets or other cross-account mechanisms.

- Use clear, consistent, and descriptive export names. Choose a naming convention (for example,
project-env-resource) and apply it consistently so teams can find and import the correct outputs. - Track exports centrally (documentation, inventory, or a registry) so teams know which outputs are available and where they originate.
- Avoid circular dependencies. Do not make Stack A depend on Stack B while Stack B depends on Stack A; such cycles block deployments and deletions.
- Keep individual templates manageable—aim for a reasonable resource count (for many teams, keeping templates under ~500 resources helps avoid long processing times and complexity).
- Store templates and artifacts in source control (Git) or centralized artifact storage (Amazon S3) for versioning and consistent access.
Export names must be unique within the same AWS account and Region. If you change an export name, remove all imports that reference it first—CloudFormation does not allow renaming an exported value while it is still imported by other stacks.
- Use nested stacks when resources are tightly coupled and you want a clear parent/child lifecycle.
- Use cross-stack references when consumers are loosely coupled but need shared values (IDs, ARNs).
- Use StackSets for multi-account, cross-Region replication of agreed patterns—this supports governance at scale.
- Keep a registry or README that documents available exports, their naming conventions, owners, and update procedures.
Stack deletions will fail if another stack is still importing an exported value. Before deleting or renaming exported outputs, remove or update all importing stacks. Avoid long chains of dependencies that become difficult to delete or update.
- Export names must be unique within the same AWS account and Region—track them carefully.
- You cannot update an export name while it is being imported; you must remove imports first.
- Deleting a stack that is referenced by others will fail until references are removed.


- Modularization via nested stacks, StackSets, and cross-stack references helps teams build consistent, reusable, and maintainable infrastructure.
- Choose nested stacks for tight coupling and hierarchy, StackSets for multi-account/Region replication, and cross-stack references to share outputs without duplication.
- Track exports, avoid circular dependencies, and plan deletion/rename workflows before changing exported values.
- AWS CloudFormation documentation
- AWS StackSets
- CloudFormation Exports and Imports
- Version and store templates in Git: Git Documentation
- Artifact storage: Amazon S3