Use a blue/green deployment with the HalfAtATime configuration and the BeforeAllowTraffic hook to delete temporary files
Short answer
C Use a blue/green deployment with HalfAtATime traffic shifting and the BeforeAllowTraffic hook to delete temporary files.
Question
Key Takeaways
The requirement to reroute traffic to half of the new instances at a time and to succeed if that half is healthy is precisely what the HalfAtATime deployment configuration does, and only blue/green supports the automatic replacement fleet and the distinct traffic-shift phase (C). The ordering requirement is what selects the hook: temporary files must be deleted before traffic reaches the new fleet, so BeforeAllowTraffic is correct, whereas BeforeBlockTraffic in option B runs at a different lifecycle point and the custom configuration with minimum healthy hosts applies to rolling deployments, not blue/green traffic shifting.
The requirements describe a blue/green deployment on an Application Load Balancer: a replacement fleet is launched automatically with no manual provisioning, traffic shifts to the new fleet half at a time, the deployment succeeds if that first half is healthy, temporary files must be deleted before traffic is routed, and the original instances must be terminated immediately on success. Blue/green with the automatically copy Auto Scaling group option satisfies the fleet requirement, CodeDeployDefault.HalfAtATime provides half-at-a-time traffic shifting with success determined by that first batch, the BeforeAllowTraffic hook deletes the temporary files before any traffic is routed, and terminating the original instances is configured on the deployment group.
Common mistake: Using the BeforeBlockTraffic hook to delete temporary files (B) — this hook fires around blocking traffic to the original instances rather than before traffic is allowed to the new environment, so it does not guarantee the files are gone before the new fleet receives traffic. Using an in-place deployment (A and D) — in-place updates instances in the deployment group in place and has no separate new fleet and traffic-shift phase, so the requirement for a newly launched fleet and half-at-a-time traffic shifting cannot be met. Using CodeDeployDefault.AllAtOnce (D) shifts all traffic at once, which contradicts the half-at-a-time requirement.
Expert Analysis
Why the Answer Is Correct
Each requirement maps to a specific part of the blue/green configuration. The replacement fleet must be launched automatically with no manual provisioning, which is what the Automatically copy Auto Scaling group option does when the deployment group is associated with an Auto Scaling group (C). Traffic must be rerouted to the new instances half at a time and the deployment must succeed if that first half is healthy, which is the behavior of the CodeDeployDefault.HalfAtATime deployment configuration: it shifts traffic to half the new fleet, and only if that succeeds does it continue to the remainder. The temporary files must be deleted before traffic is routed to the new fleet, which is exactly the BeforeAllowTraffic lifecycle event in appspec.yml, since it fires before the load balancer is allowed to send traffic to the replacement instances. Finally, instructing CodeDeploy to terminate the original instances immediately on success removes the cost of the old fleet. C is the correct answer.
Why the Other Options Are Wrong
A uses an Application Load Balancer with an in-place deployment and the OneAtATime configuration. In-place deployments roll updates by replacing instances in the deployment group in place; there is no separately launched fleet and no traffic-shift phase, so the requirements for an automatically launched new fleet and for rerouting traffic to half of the new instances at a time cannot be satisfied. B uses blue/green correctly for the fleet, but deletes the temporary files with the BeforeBlockTraffic hook and uses a custom deployment configuration with minimum healthy hosts set to 50 percent. Minimum healthy hosts is a rolling-deployment concept, and BeforeBlockTraffic fires in the block-traffic phase rather than before traffic is allowed to the new environment, so the required ordering is not met. D uses an in-place deployment with the AllAtOnce configuration, which fails both the fleet requirement and the half-at-a-time traffic requirement. C is correct.
Community Comment Notes
Community voted C unanimously. jamesf enumerated that C meets all the requirements through the blue/green strategy, the correct traffic routing configuration, the proper temporary-file cleanup timing, and automatic instance termination. trungtd identified that the Automatically copy Auto Scaling group option launches the new fleet automatically and that HalfAtATime provides the half-at-a-time shift. 6ef9a08 selected C but described the configuration as blue/green with HalfAtATime, consistent with the answer. No alternative received support.
Official Reference
- https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html
- https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html
These links open the official vendor documentation in a new tab.
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 4 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 4
-
jamesf 👍 3 Answered COption C is the best choice as it meets all the given requirements by utilizing a blue/green deployment strategy, correct traffic routing, proper temporary file cleanup timing, and automatic instance termination to manage costs. Option B is wrong due to: - Allows for custom deployment configuration, ensuring at least 50% of the instances must be healthy. However, "reroute to half" is somewhat ambiguous, as custom deployment with 50% only ensures half remain healthy but doesn't explicitly guarantee half reroute. - Uses BeforeBlockTraffic hook, which is not the correct timing for cleaning up temporary files because it should occur after instance provisioning but before allowing traffic.
-
6ef9a08 👍 3 Answered CB: blue/green deployment with CodeDeployDefault.HalfAtAtime
-
trungtd 👍 2 Answered CAutomatically Copy Auto Scaling Group: This option allows launching a new fleet of instances for each deployment automatically. CodeDeployDefault.HalfAtAtime Deployment Configuration: This configuration meets the requirement of rerouting traffic to half of the new instances at a time. It ensures that the deployment succeeds if traffic is rerouted to at least half of the instances, otherwise, it fails.
-
tgv 👍 1---> C
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →