AWS Certified Developer – Associate — Question 397

A software company is using AWS CodeBuild to build an application. The buildspec runs the application build and creates a Docker image that contains the application. The company needs to push the Docker image to Amazon Elastic Container Registry (Amazon ECR) only upon the completion of each successful build.
Which solution meets these requirements?

Answer options

Correct answer: A

Explanation

In AWS CodeBuild, the commands specified in the 'commands' block of a phase (like post_build) will only run if the preceding build phases succeeded. Conversely, commands in a 'finally' block execute regardless of build success or failure, which does not meet the requirement to push only upon successful builds. Using the artifacts sequence or a batch build matrix are incorrect methods for pushing Docker images to Amazon ECR.