DOP-C02 Question 12
Single answerYour company uses AWS CodePipeline for CI/CD, and you have a deployment stage configured to deploy an application to an Amazon ECS service using AWS CodeDeploy. Recently, deployments have been failing due to application errors found in the post-deployment validation step. The team has requested a solution to automatically roll back the deployment if these errors occur. How can you implement this in the most efficient way?
- A
Enable the 'Automatic Rollback on Deployment Failure' setting in the CodeDeploy deployment group.
- B
Modify the CodePipeline stage to include a manual approval step after deployment.
- C
Configure an Amazon CloudWatch alarm to monitor the ECS service and trigger a rollback if the alarm is breached.
- D
Write a custom Lambda function to monitor deployment events and programmatically trigger a rollback on failure.
Show answer and explanation
Correct answer: A
Explanation
AWS CodeDeploy provides a built-in 'Automatic Rollback on Deployment Failure' feature that simplifies rollback handling without requiring additional configurations or custom logic. This is the most efficient and recommended approach for handling deployment failures in ECS services managed by CodeDeploy.
- A. Correct.
This is the correct solution. Enabling the 'Automatic Rollback on Deployment Failure' setting in the deployment group will ensure that CodeDeploy automatically reverts to the previous version if errors occur during the deployment.
- B. Incorrect.
Adding a manual approval step introduces unnecessary human intervention and doesn't address the rollback requirement automatically.
- C. Incorrect.
While monitoring with a CloudWatch alarm is useful for ongoing application health, it is not the most direct or efficient way to implement automatic rollback in CodeDeploy.
- D. Incorrect.
Although writing a custom Lambda function could achieve the desired behavior, it requires additional effort and maintenance, making it a less efficient solution compared to using the built-in rollback feature.