Question

Difficulty: HardDeployment Strategies and Execution

A SysOps administrator is managing an AWS CloudFormation template that deploys a web application hosted on Amazon EC2 instances within an Auto Scaling group (ASG) behind an Application Load Balancer. The ASG has a desired capacity of 44 instances. The administrator is preparing to deploy an application update by updating the Amazon Machine Image (AMI) reference in the ASG's Launch Template.

The deployment must satisfy the following operational requirements:
- The update must be zero-downtime and maintain at least the desired capacity of 44 healthy instances in service throughout the entire update process.
- Each new instance must be verified as fully initialized and running the application successfully before any existing instance is terminated.
- If any new instance fails to initialize within a specified timeframe, the deployment must automatically roll back to the original Launch Template version without administrative intervention.

Which configuration should the administrator implement to meet these requirements?

  1. A
    Set the CloudFormation UpdatePolicy for the ASG to use AutoScalingReplacingUpdate. Configure WaitOnResourceSignals to false, and rely on the Application Load Balancer's target group health checks to automatically trigger a rollback of the CloudFormation stack if any new instance is marked unhealthy.
  2. B
    Use AWS Systems Manager Run Command to perform an in-place update of the application code on the existing EC2 instances. Configure an AWS Config rule to monitor the instance compliance status and trigger a rollback if any instance reports a non-compliant state.
  3. Set the CloudFormation UpdatePolicy for the ASG to use AutoScalingRollingUpdate. Configure MinInstancesInService to 44, MaxBatchSize to 22, and WaitOnResourceSignals to true. In the Launch Template UserData, execute the cfn-signal helper script after the application starts and passes health checks.Answer
  4. D
    Set the CloudFormation UpdatePolicy for the ASG to use AutoScalingRollingUpdate. Configure MinInstancesInService to 44 and WaitOnResourceSignals to true. Configure the EC2 instance profile to allow the instances to assume an IAM role with stack update permissions so they can update the CloudFormation stack status directly via the AWS CLI.

Answer

Set the CloudFormation UpdatePolicy for the ASG to use AutoScalingRollingUpdate, configure MinInstancesInService to 4, MaxBatchSize to 2, and WaitOnResourceSignals to true, and execute the cfn-signal helper script in the UserData after the application starts and passes health checks.
To perform a rolling update that maintains the desired capacity of 44 instances, you must use the AutoScalingRollingUpdate update policy with MinInstancesInService set to 44. Because the desired capacity is 44, CloudFormation will launch new instances first (up to the MaxBatchSize of 22) before terminating any old instances, temporarily expanding the Auto Scaling group size to 66. Setting WaitOnResourceSignals to true forces CloudFormation to wait for the cfn-signal script to be executed from within the instances' UserData before considering them healthy and proceeding with the update. If the signals are not received within the timeout period, CloudFormation aborts the update and rolls back the Auto Scaling group to its original launch template configuration, preventing downtime.

Step-by-Step Solution

1
Determine the rolling update policy and capacity constraint.
Select AutoScalingRollingUpdate and set MinInstancesInService to 44.
This guarantees that the active instance count does not fall below the desired capacity of 44 during the deployment.
2
Configure the update batch size and temporary capacity expansion.
Set MaxBatchSize to 22.
This allows CloudFormation to temporarily launch 22 new instances (bringing the total to 66) before terminating any old instances, since the minimum in-service capacity of 44 must be maintained.
3
Implement health verification and rollback triggers.
Set WaitOnResourceSignals to true and add cfn-signal to UserData.
This forces CloudFormation to pause the update until the new instances signal that the application is running successfully. If a signal is not received within the timeout, CloudFormation automatically rolls back the stack.

Key Concept

AWS CloudFormation Auto Scaling Group Rolling Updates with Resource Signals
Estimated Time:2m 0s
Rate this question