Question

Difficulty: HardAWS CloudFormation Stack and Drift Management

A SysOps Administrator manages an infrastructure stack deployed via AWS CloudFormation. The stack contains an Amazon EC2 instance and an Amazon RDS DB instance. Due to an emergency performance issue, a database administrator manually modified the RDS DB instance parameter group via the RDS console. Similarly, a systems engineer manually changed the EC2 instance type from t3.medium to m5.large via the EC2 console. The SysOps Administrator needs to update the stack to add a new Amazon S3 bucket. The administrator prepares a new CloudFormation template that includes the S3 bucket resource. The template definitions for the EC2 instance (specifying t3.medium) and the RDS DB instance remain identical to the original template. After the administrator successfully completes the stack update using the new template, what will be the configuration of the EC2 instance type and the RDS DB instance parameter group?

  1. The EC2 instance type remains m5.large and the RDS DB instance retains the manually modified parameter group.Answer
  2. B
    The EC2 instance type is reverted to t3.medium and the RDS DB instance is reverted to the original parameter group.
  3. C
    The stack update fails and triggers a rollback because CloudFormation detects the resource drift before applying the changes.
  4. D
    The EC2 instance type is reverted to t3.medium but the RDS DB instance retains the manually modified parameter group.

Answer

The EC2 instance type remains m5.large and the RDS DB instance retains the manually modified parameter group.
The option stating that the EC2 instance type remains m5.large and the RDS DB instance retains the manually modified parameter group is correct. AWS CloudFormation evaluates changes by comparing the submitted template against the previously deployed template. Because the template definitions for the EC2 and RDS instances are identical in both templates, CloudFormation does not include these resources in the update execution plan. Consequently, the drift (the manual changes) is not detected or overwritten, and it persists after the stack update completes.

Step-by-Step Solution

1
Analyze how AWS CloudFormation processes stack updates.
Confirm that CloudFormation updates resources based on the differences between the newly submitted template and the template last used for the stack update, rather than the live state of the resources.
To understand that CloudFormation does not automatically inspect live resource configuration during standard updates.
2
Check the modifications in the new template.
Note that the S3 bucket is the only new addition, and the configurations for both the EC2 instance and the RDS DB instance are unchanged compared to the previous template.
To determine which resources will be included in the CloudFormation change set for modification.
3
Evaluate the state of the drifted resources post-update.
Because no template changes were made to the EC2 or RDS configurations, CloudFormation bypasses updating these resources, meaning the manually modified states (m5.large for the EC2 instance and the custom parameter group for the RDS DB instance) remain intact.
To identify that the drifted properties persist as they were not target properties for modification in the template update.

Key Concept

CloudFormation Stack Update Behavior with Drifted Resources
Rate this question