
Answer-first summary for fast verification
Answer: Include a hooks section in the CodeDeploy AppSpec file. Use the AfterAllowTestTraffic lifecycle event to trigger an AWS Lambda function that runs the test scripts. If errors are detected, terminate the Lambda function with an error code to initiate a rollback.
The correct answer is C. Adding a hooks section to the CodeDeploy AppSpec file and using the AfterAllowTestTraffic lifecycle event to invoke an AWS Lambda function ensures that the test scripts run after the new version of the application is deployed but before the traffic is shifted. If the test scripts detect any errors, the Lambda function should exit with an error code, which will automatically initiate a rollback of the deployment. This approach directly leverages CodeDeploy lifecycle hooks to manage testing and rollback efficiently.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company is automating its release pipeline using AWS CodePipeline and deploying applications to Amazon ECS with AWS CodeDeploy in a blue/green deployment model. They need to run test scripts on the new 'green' version of the application within 5 minutes before traffic is shifted. If any errors are detected during these tests, the deployment must be rolled back. Which strategy should be employed to meet these testing and rollback requirements?
A
Insert a stage in the CodePipeline between the source and deploy stages. Utilize AWS CodeBuild to establish a runtime environment and execute test scripts via build commands in the buildspec file. If errors are detected, halt the deployment using the aws deploy stop-deployment command.
B
Insert a stage in the CodePipeline between the source and deploy stages. Invoke an AWS Lambda function in this stage to execute the test scripts. If errors are detected, halt the deployment using the aws deploy stop-deployment command.
C
Include a hooks section in the CodeDeploy AppSpec file. Use the AfterAllowTestTraffic lifecycle event to trigger an AWS Lambda function that runs the test scripts. If errors are detected, terminate the Lambda function with an error code to initiate a rollback.
D
Include a hooks section in the CodeDeploy AppSpec file. Use the AfterAllowTraffic lifecycle event to trigger the test scripts. If errors are detected, halt the deployment using the aws deploy stop-deployment CLI command.