What Is AWS CloudFormation? Manage Stack Deployments and Changes Safely
AWS CloudFormation is an infrastructure management service that creates, changes, and deletes AWS resources declared in YAML or JSON templates as a unit called a stack. A template describes the intended configuration; CloudFormation calls AWS service APIs to provision resources, coordinates dependencies, and records operation status. A change set previews a plan but does not guarantee success. Service capacity, permissions, runtime failures, and manual changes outside the template still need separate attention.
AWS CloudFormation is an infrastructure management service that creates, changes, and deletes AWS resources declared in YAML or JSON templates as a unit called a stack. A template describes the intended configuration; CloudFormation calls AWS service APIs to provision resources, coordinates dependencies, and records operation status. A change set previews a plan but does not guarantee success. Service capacity, permissions, runtime failures, and manual changes outside the template still need separate attention.
How do templates and stacks fit together?
A template declares resources such as EC2 instances, security groups, and S3 buckets, along with their properties. Parameters can supply environment-specific values, while references and conditions express relationships. A stack is the unit that manages the actual collection of AWS resources described by a template. CloudFormation submits the API calls each resource needs; the execution principal must have the IAM permissions to create or modify those resources.
Imagine a web application stack with a network, servers, security groups, and log storage. If a server depends on a security group, CloudFormation accounts for that relationship when ordering operations; independent resources can be provisioned in parallel. A team can use the same template and inputs to manage development and production stacks instead of creating every resource manually in the console. Before deleting a stack, however, decide whether data stores should be removed or retained through resource policies and lifecycle choices.
What happens during create and update operations?
To create a stack, submit a template and any parameter values. CloudFormation performs pre-deployment validation for common issues such as syntax, property, or name conflicts, then provisions resources. If creation fails, the default behavior is to roll back resources created during that operation. Depending on operation settings and failure type, you can instead preserve successfully provisioned resources for investigation and a later retry. Stack events show per-resource progress and failure reasons, so start with the earliest failed resource.
To change an existing stack, modify the template or parameters and create a change set. It previews resources to add, modify, or delete, and some property changes, without applying the update until you execute it. After review, executing the change set starts the update. If it fails, CloudFormation attempts to roll back to the last known working state. Depending on resource properties, an update may interrupt service or replace a resource with a new one. Pay particular attention to databases, network boundaries, public addresses, and other changes with data or availability impact.
A change set does not ensure that the update will succeed. The plan may not validate every condition during execution. Quotas, permissions, service-specific constraints, custom-resource code, or external service state can still cause a runtime failure. For important changes, review the resource-specific update behavior, backup and recovery steps, approvals, and deployment window alongside the change set.
How do you find manual changes outside the template?
An operator may modify a stack resource directly in the EC2 console or through another AWS tool. The actual configuration can then differ from the configuration expected by the template; this is called drift. Later stack updates or deletion may fail or make an unintended change because CloudFormation’s expected state no longer matches reality.
Drift detection compares current properties of supported resources with expected values explicitly specified in the template and parameters. It does not check every resource type or every property. Unsupported resources may remain NOT_CHECKED; defaults omitted from the template and sensitive values not returned by the underlying service may be outside the comparison. Therefore, IN_SYNC means the supported, checked properties match; it does not prove every resource in the account is fully represented by the template.
When drift appears, first determine whether the manual change was an intentional emergency response. Then choose whether to update the template to reflect the intended configuration or restore the actual resource to match the template. Record the decision and owner, and run detection again after remediation. A parent stack’s drift check may not automatically examine every nested stack, so inspect nested stacks separately when needed.
What should you do when deployment or rollback fails?
Start with the stack status and events. Identify the earliest failed resource, its error code, and the reason. Common causes include invalid properties, insufficient IAM permissions, service quotas, resources that did not stabilize, or resources changed or deleted manually. If the template is wrong, correct it before an update. If permissions or a temporary service issue caused the failure, fix the condition and retry where appropriate.
If rollback stops in UPDATE_ROLLBACK_FAILED, do not begin by skipping resources. First address the cause and continue rollback to return the stack to a usable state. CloudFormation can allow specific resources to be skipped, but skipped resources may no longer match the template. A later update can be harder or fail, so reconcile those resources with the template or revise the stack definition and verify it before proceeding.
A practical review sequence
**Confirm the target:** verify account, Region, stack name, and template version.
**Review authority and inputs:** check the execution role, parameters, referenced files, and treatment of sensitive values.
**Review the change set:** identify additions, modifications, deletions, and replacements; assess data loss and availability impact.
**Watch the operation:** follow stack events and investigate the first failure. Avoid repeating the same update blindly during rollback.
**Compare actual state:** run drift detection when needed and resolve changes outside the template.
**Check cleanup and cost:** inspect resources retained by deletion policies and identify data or billable resources left outside the stack.
CloudFormation’s central value is managing desired state and change history for related AWS resources as a stack. A template does not guarantee that every resource always matches it. Safe deployment and recovery require checking change sets, events, drift results, IAM permissions, and resource-specific behavior together.
Sources
[How AWS CloudFormation works](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-overview.html)
[Update stacks using CloudFormation change sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html)
[CloudFormation drift detection](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html)
[Troubleshooting CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html)
[Stack failure options](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-failure-options.html)