Soru

Zorluk: ZorDeployment Strategy Design

An enterprise is designing a deployment pipeline for a critical transaction-processing application. The application runs on Amazon EC2 instances managed by an Auto Scaling group (ASG) behind an Application Load Balancer (ALB). The infrastructure is defined and managed using AWS CloudFormation. The application processes long-running database transactions that can take up to 1212 minutes to complete; interrupting these transactions results in data corruption. The deployment strategy must meet the following requirements:

1. Roll out updates with zero downtime.
2. Ensure that instances are never terminated while processing active transactions.
3. Automatically roll back the CloudFormation stack to the previous version if new instances fail to initialize or fail application-level health checks.
4. Minimize additional compute costs by avoiding the pre-allocation of a duplicate Auto Scaling group during the deployment.

Which configuration strategy should the Solutions Architect implement to meet these requirements?

  1. Update the CloudFormation template to configure the ASG `UpdatePolicy` with `AutoScalingRollingUpdate`. Set `WaitOnResourceSignals` to `true` and define an appropriate `Timeout`. Configure an `EC2_INSTANCE_TERMINATING` lifecycle hook on the ASG that runs a script to wait for active connections to drain before completing the hook. In the EC2 user data, start the application, run a local health check script, and invoke the `cfn-signal` helper utility upon success.Cevap
  2. B
    Update the CloudFormation template to configure the ASG `UpdatePolicy` with `AutoScalingReplacingUpdate`. Rely on the ALB target group's default deregistration delay to drain connections. Configure the CloudFormation stack with a rollback trigger based on CloudWatch alarms monitoring the application's health.
  3. C
    Configure AWS CodeDeploy to perform an In-Place deployment using a `CodeDeployDefault.AllAtOnce` configuration. Use a CodeDeploy `ApplicationStop` lifecycle hook to wait for active connections to drain. Configure CloudWatch alarms to trigger a CodeDeploy automatic rollback on deployment failure.
  4. D
    Create a new AWS CloudFormation template that uses the `AWS::CodeDeploy::BlueGreen` hook to manage the EC2 Auto Scaling group deployment. Configure the deployment group to use a canary shifting strategy and monitor CloudWatch alarms to trigger an automatic rollback.

Cevap

Configure the Auto Scaling group's CloudFormation UpdatePolicy to use AutoScalingRollingUpdate, enable WaitOnResourceSignals, implement an EC2_INSTANCE_TERMINATING lifecycle hook, and use the cfn-signal helper utility in the EC2 user data.
The correct strategy uses the `AutoScalingRollingUpdate` policy in CloudFormation to update instances in place, which avoids the cost of a duplicate Auto Scaling group. By setting `WaitOnResourceSignals` to true and using `cfn-signal` in the EC2 user data, CloudFormation ensures that the application is fully running and healthy before continuing the rollout, automatically rolling back if any batch fails. The `EC2_INSTANCE_TERMINATING` lifecycle hook allows the instances to finish their long-running transactions (up to 1212 minutes) before they are terminated, preventing data corruption.

Adım Adım Çözüm

1
Configure the CloudFormation UpdatePolicy on the AWS::AutoScaling::AutoScalingGroup resource to use AutoScalingRollingUpdate.
This ensures that updates are rolled out in batches, maintaining service availability and avoiding the cost of a duplicate Auto Scaling group.
Meets the requirements of zero downtime and minimized resource costs during deployment.
2
Enable WaitOnResourceSignals and configure an appropriate Timeout in the AutoScalingRollingUpdate policy.
CloudFormation will pause the update and wait for a success signal from each newly launched EC2 instance before updating subsequent batches.
Allows CloudFormation to automatically roll back the stack if new instances fail to start or report healthy within the timeout period.
3
Configure an EC2_INSTANCE_TERMINATING lifecycle hook on the Auto Scaling group.
When an instance is selected for termination during the rolling update, the lifecycle hook transitions the instance to the Terminating:Wait state.
This pauses termination and allows a custom script or daemon on the instance to complete any ongoing long-running transactions (up to the 1212-minute limit) before signaling completion.
4
In the EC2 user data script, configure the application startup, run a local health check to verify its readiness, and call the cfn-signal utility.
Once the application is verified as fully functional on the new instance, a success signal is sent to CloudFormation.
Ensures that CloudFormation only proceeds with the deployment when the new version is confirmed healthy, triggering a rollback if the signal fails.

Anahtar Kavram

Auto Scaling Rolling Updates with Lifecycle Hooks and CloudFormation Signals
Bu soruyu puanla