Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.3.2.5. Remediating a Non-Desired System State

3.3.2.5. Remediating a Non-Desired System State

When your system drifts from its desired state — whether from manual changes, failed deployments, or configuration corruption — you need automated mechanisms to detect and correct the drift.

Detection mechanisms:
  • CloudFormation drift detection: Compares actual resource configuration against the template
  • Config rules: Continuously evaluate resource compliance
  • SSM State Manager: Checks association compliance on schedule
  • Terraform plan: Shows differences between state file and actual infrastructure
Remediation strategies by drift type:
Drift TypeDetectionRemediation
CloudFormation resource modifiedCFN drift detectionStack update to revert changes
Security group rule added manuallyConfig rule restricted-sshSSM Automation removes rule
Instance missing required packageState Manager association failureState Manager re-applies on next run
S3 bucket encryption disabledConfig rule s3-bucket-encryptionLambda enables encryption
Tags missing on new resourceConfig rule + tag policyLambda applies default tags
CloudFormation drift remediation:
# Detect drift
aws cloudformation detect-stack-drift --stack-name MyStack

# After detection completes, review drifted resources
aws cloudformation describe-stack-resource-drifts \
  --stack-name MyStack \
  --stack-resource-drift-status-filters MODIFIED DELETED

# Remediate by updating the stack (reimports actual state or reverts)
aws cloudformation update-stack --stack-name MyStack \
  --use-previous-template

Exam Trap: CloudFormation can detect drift but cannot automatically remediate it. Drift detection shows what changed; you must decide whether to update the template to match reality (accept the drift) or update the stack to revert the change (reject the drift). If the exam asks about automatic drift remediation, the answer is Config rules + SSM Automation, not CloudFormation drift detection alone.

Alvin Varughese
Written byAlvin Varughese•Founder•15 professional certifications