Question 4
Domain 1: SDLC AutomationA company is using AWS CodeDeploy to automate software deployment. The deployment must meet these requirements: A number of instances must be available to serve traffic during the deployment. Traffic must be balanced across those instances, and the instances must automatically heal in the event of failure. A new fleet of instances must be launched for deploying a new revision automatically, with no manual provisioning. Traffic must be rerouted to the new environment to half of the new instances at a time. The deployment should succeed if traffic is rerouted to at least half of the instances: otherwise, it should fail. Before routing traffic to the new fleet of instances, the temporary files generated during the deployment process must be deleted. At the end of a successful deployment, the original instances in the deployment group must be deleted immediately to reduce costs. How can a DevOps engineer meet these requirements?
Correct answer: C
Explanation
A blue/green deployment with an Application Load Balancer and Auto Scaling group fits the need to “launch a new fleet of instances” and “reroute traffic” while keeping instances available and load-balanced. CodeDeploy’s “Automatically copy Auto Scaling group” creates the replacement fleet, “CodeDeployDefault.HalfAtATime” shifts traffic in halves, the “BeforeAllowTraffic” hook removes temporary files before cutover, and terminating the original instances after success reduces costs.
Why each option is right or wrong
A. Use an Application Load Balancer and an in-place deployment. Associate the Auto Scaling group with the deployment group. Use the Automatically copy Auto Scaling group option, and use CodeDeployDefault.OneAtAtime as the deployment configuration. Instruct AWS CodeDeploy to terminate the original instances in the deployment group, and use the AllowTraffic hook within appspec.yml to delete the temporary files.
In-place deployment updates existing instances, not a newly launched replacement fleet.
B. Use an Application Load Balancer and a blue/green deployment. Associate the Auto Scaling group and Application Load Balancer target group with the deployment group. Use the Automatically copy Auto Scaling group option, create a custom deployment configuration with minimum healthy hosts defined as 50%, and assign the configuration to the deployment group. Instruct AWS CodeDeploy to terminate the original instances in the deployment group, and use the BeforeBlockTraffic hook within appspec.yml to delete the temporary files.
BeforeBlockTraffic runs on the old environment before traffic is stopped, not before new instances receive traffic.
C. Use an Application Load Balancer and a blue/green deployment. Associate the Auto Scaling group and the Application Load Balancer target group with the deployment group. Use the Automatically copy Auto Scaling group option, and use CodeDeployDefault.HalfAtAtime as the deployment configuration. Instruct AWS CodeDeploy to terminate the original instances in the deployment group, and use the BeforeAllowTraffic hook within appspec.yml to delete the temporary files.
AWS CodeDeploy blue/green deployments are the only model here that provisions a replacement fleet automatically and then shifts live traffic to it through an Application Load Balancer; the deployment group must be linked to both the Auto Scaling group and the ALB target group so the service can keep instances healthy and load-balanced during cutover. The `CodeDeployDefault.HalfAtATime` deployment configuration shifts traffic in 50% increments, and the deployment fails if the traffic shift cannot complete for at least half of the instances; the `BeforeAllowTraffic` lifecycle event in `appspec.yml` is the correct point to delete temporary files before any production traffic reaches the new fleet. Finally, setting CodeDeploy to terminate the original instances after a successful blue/green deployment immediately removes the old environment and satisfies the cost-reduction requirement.
D. Use an Application Load Balancer and an in-place deployment. Associate the Auto Scaling group and Application Load Balancer target group with the deployment group. Use the Automatically copy Auto Scaling group option, and use CodeDeployDefault.AllatOnce as a deployment configuration. Instruct AWS CodeDeploy to terminate the original instances in the deployment group, and use the BlockTraffic hook within appspec.yml to delete the temporary files.
AllAtOnce shifts traffic to all instances together and in-place does not create a separate green fleet.