DOP-C02 Question 351
Single answerYour team is managing a CI/CD pipeline in AWS CodePipeline. During a recent deployment, the application failed to deploy to an Amazon ECS cluster due to a mismatched image tag. The team wants to ensure that any future deployments automatically validate that the container image tag referenced in the ECS task definition matches the image tag built and pushed by the pipeline. Which solution will effectively address this issue?
- A
Use AWS CodeBuild to validate the image tag in the buildspec file and stop the pipeline if there is a mismatch.
- B
Add a manual approval step in the pipeline to allow a team member to verify the image tag before deployment.
- C
Implement a Lambda function triggered by the CodePipeline to validate the image tag and fail the deployment if it doesn't match.
- D
Enable the 'ImageTagValidation' option in the ECS task definition to automatically validate the image tag during deployment.
Show answer and explanation
Correct answer: C
Explanation
The correct approach to ensure image tag validation in an automated CI/CD pipeline is to use a Lambda function that can be triggered during the pipeline execution. The Lambda function can programmatically compare the image tag used in the ECS task definition with the tag pushed by the pipeline. This solution is fully automated and aligns with DevOps best practices, making it the most appropriate answer.
- A. Incorrect.
AWS CodeBuild buildspec files are used for defining build tasks, but they are not capable of validating the image tag during the deployment stage. This option is not feasible for the described issue.
- B. Incorrect.
While a manual approval step would allow a human to verify the image tag, it introduces inefficiency and does not automate the task of validation. This does not align well with DevOps principles of automation.
- C. Correct.
Integrating a Lambda function into the pipeline to validate the image tag ensures that the pipeline automatically verifies the image tag during deployment. This is a scalable and automated solution to prevent mismatches.
- D. Incorrect.
ECS task definitions do not have a built-in 'ImageTagValidation' option. This choice is invalid as it refers to a non-existent feature.