A template describes; a stack deploys
How reusable JSON or YAML templates define resources that CloudFormation provisions and manages together as stacks for repeatable deployments. · foundational
AWS CloudFormation provisions and manages AWS resources from a text file called a template. You write the template in JSON or YAML to describe the resources you want and their settings, rather than manually creating each resource. This approach is called infrastructure as code.
A stack is a collection of resources that CloudFormation manages as one unit. For example, a template could describe an S3 bucket and a DynamoDB table. Creating a stack from that template tells CloudFormation to provision those resources and track them together.
The template is the reusable definition, not the running infrastructure. You can use one template to create multiple stacks, each with its own resources. Keeping the definition in a file makes it easier to review, share, and repeat a deployment without repeating manual setup.
| Aspect | Template | Stack |
|---|---|---|
| What it is | JSON or YAML definition | Managed resource collection |
| What it contains | Resource declarations | Provisioned resources |
| How it is reused | Create multiple stacks | Manage one deployment |