Skip to main content
Welcome back. In this lesson we expand on configuration drift and CloudFormation stack policies, building on concepts such as StackSets, change sets, and stacks. Configuration drift is the divergence between the infrastructure described in your declarative template (the blueprint) and the live resources running in your environment. Using a car factory analogy: the blueprint is the assembly specification and each car is a deployed resource. If a worker makes a manual change on the line and a car no longer matches the blueprint, that’s configuration drift. Manual edits or external systems can modify critical components, producing inconsistencies that cause failures and make troubleshooting harder. Drift can be introduced by:
  • Manual console edits or API calls
  • Other automation or deployment systems acting outside your template
  • Upstream dependency or configuration changes
The largest operational risk is environment inconsistency (for example, staging vs production), which can cause deployments or runtime behavior to fail unpredictably.
An infographic titled "Configuration Drift – Understanding the Risks" showing development, staging, and production boxes with AWS Lambda, Amazon S3, and Amazon EC2 icons. Development and staging have green checkmarks, while production shows a warning and a template mismatch leading to difficult troubleshooting.
Detecting drift After you create a CloudFormation stack from a template, the CloudFormation console exposes a Detect drift operation (Stack Actions). Running drift detection compares stack resources against the template and reports any differences. Common drift statuses
Exam tip: remember the common drift statuses — IN_SYNC, MODIFIED, and DELETED. You may also encounter NOT_CHECKED for resource types or properties that CloudFormation cannot evaluate.
A slide titled "Detecting Drift in CloudFormation" showing a CloudFormation console menu with a "Detect drift" option and a resource drift status table listing stack resources marked "IN_SYNC."
Remediation options When drift is detected you have multiple remediation strategies; choose based on whether the change should be preserved, reverted, or reconciled:
  • Use a change set to roll the stack back to a known good state or to apply a controlled update.
  • Update the CloudFormation template and reapply the stack to bring resources back into compliance.
  • Manually update or replace resources when the change must be preserved and then update the template to reflect the desired state.
Quick remediation reference
A presentation slide titled "Drift Remediation Strategies" showing two options side-by-side: "Rollback using Change Sets" with a diagram icon and "Manually update CloudFormation Template" with a developer icon. The slide has simple colored buttons under each option.
Preventing risky changes with stack policies Stack policies let you restrict what CloudFormation is allowed to change during stack updates. They are useful for protecting critical resources (for example, preventing updates or deletions of a production database) when updates are performed via CloudFormation. Important: stack policies only control updates made by CloudFormation. They do not prevent manual edits performed directly in the AWS console or by other APIs. Use IAM, resource policies (where available), and guardrails to control non-CloudFormation changes.
Stack policies block CloudFormation-driven updates only. If you need protection against manual console/API edits, combine stack policies with IAM restrictions, resource policies, AWS Config rules, or monitoring and automated remediation.
A diagram titled "Configuration Drift" showing AWS resources (Lambda, S3, EC2) inside an AWS Cloud with stack policies and access control rules. It shows a developer manually modifying resources that causes them to become inconsistent with an AWS CloudFormation template.
Example stack policy (deny updates to a logical S3 bucket resource)
This policy denies any CloudFormation update actions against the logical resource named MyBucket. Use the logical resource ID from your template in the Resource field. Stack policies provide a templated mechanism to prevent unintended CloudFormation-driven changes, improving infrastructure stability and security posture.
A presentation slide titled "Why Use Stack Policies?" showing a large purple "Stack Policies" cloud icon on the left and three colored icons on the right with the benefits: "Prevents accidental updates," "Ensures infrastructure stability," and "Enhances security."
Best practices
  • Run drift detection regularly and include it in operational health checks or CI/CD pipelines.
  • Integrate drift detection with monitoring and auditing tools such as AWS Config and AWS CloudTrail to track who changed what and when.
  • Define and apply stack policies for critical resources to limit unintentional updates by CloudFormation.
  • Avoid manual edits to managed infrastructure; if manual changes are required, ensure templates are updated immediately to reflect the new desired state.
  • Automate remediation and notifications: use Amazon EventBridge to trigger Systems Manager Automation documents or other workflows when AWS Config or CloudTrail detect unauthorized changes.
A presentation slide titled "Configuration Drift and Stack Policies – Best Practices" showing five icons with short recommendations. The tips: enable drift detection regularly, use AWS Config and CloudTrail for monitoring and tracking, define stack policies for critical resources, and avoid manual resource changes.
References and further reading Thanks for being here.

Watch Video