You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A CloudFormation stack is a collection of AWS resources that are created, updated, and deleted as a single unit. When you submit a template to CloudFormation, it creates a stack that tracks every resource defined in that template. Understanding how to manage stacks — creating, updating, monitoring, and deleting them — is essential for working with CloudFormation in practice.
A stack is the fundamental deployment unit in CloudFormation. It has:
Think of a stack as a single "unit of infrastructure" — all the resources in a stack are meant to work together.
CloudFormation tracks the lifecycle of each stack through a series of statuses:
| Status | Meaning |
|---|---|
CREATE_IN_PROGRESS | Resources are being created |
CREATE_COMPLETE | All resources were created successfully |
CREATE_FAILED | One or more resources failed to create |
UPDATE_IN_PROGRESS | An update is being applied |
UPDATE_COMPLETE | The update succeeded |
UPDATE_ROLLBACK_IN_PROGRESS | The update failed and is being rolled back |
UPDATE_ROLLBACK_COMPLETE | The rollback after a failed update is complete |
DELETE_IN_PROGRESS | Resources are being deleted |
DELETE_COMPLETE | All resources have been deleted |
ROLLBACK_IN_PROGRESS | Initial creation failed and resources are being cleaned up |
ROLLBACK_COMPLETE | Rollback after failed creation is complete |
aws cloudformation create-stack \
--stack-name my-app-stack \
--template-body file://template.yaml \
--parameters ParameterKey=Environment,ParameterValue=production \
ParameterKey=DBPassword,ParameterValue=MySecurePass123
For templates larger than 51,200 bytes, you must upload to S3 first:
aws s3 cp template.yaml s3://my-templates-bucket/template.yaml
aws cloudformation create-stack \
--stack-name my-app-stack \
--template-url https://my-templates-bucket.s3.amazonaws.com/template.yaml
Every action CloudFormation takes is recorded as a stack event. You can monitor events to track progress and debug failures:
aws cloudformation describe-stack-events \
--stack-name my-app-stack
Events include:
The CLI can block until a stack operation completes:
aws cloudformation wait stack-create-complete \
--stack-name my-app-stack
echo "Stack creation complete!"
This is useful in CI/CD pipelines where you need to wait before proceeding.
To update a running stack, modify your template and submit an update:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.