Courseiva
SDLC Automation →mediumMultiple Select

DOP-C02 SDLC Automation Practice Question

Which TWO actions should a DevOps engineer take to implement a CI/CD pipeline that automatically deploys a containerized application to Amazon ECS using AWS CodePipeline and AWS CodeBuild? (Choose TWO.)

⚠ Common exam trap

Candidates often confuse the role of CodeDeploy (which is for EC2/on-premises deployments) with ECS deployment mechanisms, or mistakenly think CodeCommit can store Docker images instead of source code, leading them to select options B or C.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use CodeBuild to build the Docker image and push it to Amazon ECR

AWS CodeBuild can be configured to build the Docker image from source code and then push it to Amazon ECR using the `post_build` phase with commands like `docker push`. This is a standard pattern for containerized CI/CD pipelines, as ECR serves as the private registry for storing and versioning container images. Option E is correct because CodePipeline can use Amazon ECR as a source action, which triggers the pipeline automatically when a new image is pushed to the specified repository, enabling continuous deployment to ECS.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use AWS CloudFormation to deploy the ECS service

    Why it's wrong here

    CloudFormation is an infrastructure-as-code service for provisioning and managing AWS resources, but it is not a required part of a basic CodePipeline-to-ECS deployment. CodePipeline natively supports updating an ECS service directly with the 'Amazon ECS' deploy action or via CodeDeploy, so adding CloudFormation would introduce unnecessary complexity and an extra deployment step. While you could use CloudFormation to create the ECS cluster and service initially, the pipeline itself can deploy image changes without invoking CloudFormation.

  • ✗

    Use AWS CodeDeploy to deploy the container to ECS with a blue/green deployment

    Why it's wrong here

    CodeDeploy with blue/green deployments is one valid deployment strategy for ECS, but it is an optional advanced mechanism, not a mandatory action for a basic pipeline. A minimal container pipeline only needs to build the image in CodeBuild, push it to ECR, and let CodePipeline source the new image and roll it out via the native ECS deployment action. Adding CodeDeploy would require an additional application and deployment group configuration, making the solution more complex than the question's core requirement.

  • ✗

    Store the Docker image in AWS CodeCommit

    Why it's wrong here

    CodeCommit is a managed Git repository designed for storing source code and version-controlled text files, not for hosting binary container images. Docker images are typically hundreds of megabytes or gigabytes and require a dedicated container registry that supports pull/push via the Docker API, such as Amazon ECR or Docker Hub. Attempting to store images in CodeCommit would be inefficient, violate Docker's client workflows, and is not how ECS or CodePipeline expects to consume images.

  • ✓

    Use CodeBuild to build the Docker image and push it to Amazon ECR

    Why this is correct

    CodeBuild should be used to build the Docker image because it can execute a buildspec that runs 'docker build' and then uses 'aws ecr put-image' or 'docker push' to store the image in ECR. This step is the pipeline's build stage, converting source code into an immutable container artifact tagged with a version or commit hash. Without this action, the pipeline would have no image to deploy, making it the essential first of the two required actions.

  • ✓

    Configure CodePipeline to use Amazon ECR as a source for the container image

    Why this is correct

    Configuring CodePipeline with an Amazon ECR source makes the pipeline trigger automatically whenever a new container image is pushed to the repository, rather than polling a code repository on every commit. The ECR source action pulls the image metadata and can reference an 'imagedefinitions.json' file that maps the image URI to a container name in the ECS task definition. This integration creates a continuous delivery flow where CodeBuild pushes an image, ECR detects it, and the pipeline immediately deploys it to ECS.

About these practice questions

Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.