AWS › IaC (CloudFormation)

What is a CloudFormation stack, and how does it relate to the resources defined in a template?

Beginner

Answer

A CloudFormation stack is the actual collection of AWS resources that get created when you deploy a template, and CloudFormation treats all resources within a stack as a single managed unit, meaning if you update the stack, CloudFormation calculates exactly what needs to change, and if you delete the stack, CloudFormation automatically cleans up every resource that was created as part of it, preventing orphaned resources from being accidentally left behind.
aws cloudformation describe-stacks --stack-name my-stack
Real-world example A developer deletes an entire test environment, consisting of a dozen different resources, with a single command by deleting its CloudFormation stack, confident that CloudFormation will properly clean up every associated resource rather than needing to manually track and delete each one individually.

Common follow-ups: What happens if you manually modify a resource that was created by CloudFormation?;How do you protect specific critical resources within a stack from being accidentally deleted?