Soru

Zorluk: OrtaAWS CloudFormation Stack and Drift Management

A SysOps Administrator is managing an infrastructure stack deployed via AWS CloudFormation. After running drift detection on the stack, the administrator notices that an Amazon EC2 instance's type was manually changed from t3.micro to t3.small by another team member using the Amazon EC2 console. The CloudFormation template still specifies the instance type as t3.micro. The administrator wants to return the EC2 instance to the configuration defined in the template without redeploying the entire stack.

Which of the following is the correct method to resolve this drift?

  1. Manually modify the EC2 instance type back to t3.micro using the Amazon EC2 console or AWS CLI, and then run drift detection on the CloudFormation stack to confirm that the resource status returns to IN_SYNC.Cevap
  2. B
    Initiate a stack update using the original template with no changes to force CloudFormation to detect the difference between the template and the live state of the EC2 instance and automatically overwrite the manual changes.
  3. C
    Modify the CloudFormation stack service role policy to include the iam:PassRole permission, and initiate a stack update to force a service trust policy evaluation that automatically remediates the drifted instance configuration.
  4. D
    Configure the stack rollback options to enable automated drift remediation, and run the aws cloudformation rebuild-stack CLI command to re-create the drifted EC2 instance using a blue/green deployment strategy.

Cevap

Manually modify the EC2 instance type back to t3.micro using the Amazon EC2 console or AWS CLI, and then run drift detection on the CloudFormation stack to confirm that the resource status returns to IN_SYNC.
The correct method to remediate manual resource changes and align them back with the CloudFormation stack configuration is to manually change the resource properties back to their original values (e.g., changing the instance type from t3.small back to t3.micro via the EC2 console or CLI) and then re-running drift detection to update the status to IN_SYNC. CloudFormation does not have an automated feature to overwrite manual changes on demand without template modifications.

Adım Adım Çözüm

1
Change the instance type manually back to the expected template value.
The instance type is changed from t3.small to t3.micro using the EC2 console or AWS CLI.
CloudFormation does not automatically overwrite drift when no template changes are made, so the resource must be reverted manually.
2
Run drift detection on the CloudFormation stack.
CloudFormation compares the template configuration against the actual resource state.
This updates the drift status of the stack and resources to reflect the new state.
3
Verify that the resource drift status is IN_SYNC.
The status of the EC2 instance in the drift detection results updates from DRIFTED to IN_SYNC.
Confirming the manual remediation was successful and matches the template.

Anahtar Kavram

CloudFormation drift detection identifies manual changes to stack resources outside of CloudFormation. Remediation requires manually reverting the resource properties to match the template, or updating the template to match the current resource state.
Bu soruyu puanla