Drift detection shows `MODIFIED` on a security group and an RDS instance that someone changed in the console. How do you reconcile?
AdvancedTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer
Likely causes → Changes made outside CloudFormation (console hotfix during an incident). The next stack update may silently undo them, or fail.
Diagnose →
ID=$(aws cloudformation detect-stack-drift --stack-name app --query StackDriftDetectionId --output text)
aws cloudformation describe-stack-drift-detection-status --stack-drift-detection-id $ID
aws cloudformation describe-stack-resource-drifts --stack-name app --stack-resource-drift-status-filters MODIFIED DELETED \
--query 'StackResourceDrifts[].[LogicalResourceId,PropertyDifferences]'
Fix →
- Decide which version is correct
- If the console change should stay, put it into the template and deploy a change set (it should show no replacement)
- If not, deploy the template to overwrite it
- For resources deleted out of band, remove them from the template, or re-create and import them (
create-change-set --change-set-type IMPORT)
Prevent → Run scheduled drift detection (AWS Config rule cloudformation-stack-drift-detection-check), make production console access read-only, and have a break-glass process that requires a follow-up PR.
More on CloudFormation, CloudWatch, KMS, Secrets and Cost
Updating a stack fails: `Stack:arn:aws:cloudformation:...:stack/app/... is in ROLLBACK_COMPLETE state and can not be updated.`BeginnerA stack is stuck in `UPDATE_ROLLBACK_FAILED`.AdvancedA pipeline fails with `An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed.`Beginner`InsufficientCapabilitiesException: Requires capabilities : [CAPABILITY_NAMED_IAM]`.BeginnerStack deletion ends in `DELETE_FAILED` with `The bucket you tried to delete is not empty` on an S3 bucket resource.IntermediateDeleting or updating a stack fails: `Export network-VpcId cannot be deleted as it is in use by app-stack`.Intermediate