Q94 — AWS DOP-C02 Ch.3

Question 94 of 100 | ← Chapter 3

A company uses AWS CodePipeline to automate its release pipeline. AWS CodeDeploy is used in the pipeline with a blue/green deployment model to deploy the application to Amazon ECS. The company wants to run scripts to test the green version of the application before shifting traffic. These scripts must complete within five minutes or less. If errors are detected during this testing period, the company wants to roll back the deployment.

Correct Answer: C. Add a hooks section to the CodeDeploy AppSpec file. Use the AfterAllowTestTraffic lifecycle event to invoke an AWS Lambda function that runs the test scripts. If errors are found, exit the Lambda function with an error to trigger automatic rollback.

Explanation

Option C is optimal. By adding a hook in the CodeDeploy AppSpec file and using the AfterAllowTestTraffic lifecycle event, testing occurs precisely before production traffic shifts. Invoking an AWS Lambda function enables flexible, serverless test execution. If the Lambda function fails (e.g., returns an error), CodeDeploy automatically triggers rollback—ensuring safety and reliability without custom CLI logic. Option D uses AfterAllowTraffic, which executes *after* full traffic shift, missing the pre-cutover validation window. Options A and B require external orchestration and manual rollback commands, increasing complexity and reducing reliability compared to native CodeDeploy rollback.