Courseiva
SDLC Automation →mediumMultiple Choice

DOP-C02 SDLC Automation Practice Question

You are a DevOps engineer for a company that uses AWS CodePipeline to deploy a microservice to Amazon ECS with Fargate. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild) that builds a Docker image and pushes it to Amazon ECR, and a deploy stage that uses an ECS task definition update. Recently, the deploy stage started failing intermittently with the error 'The task definition does not have a compatibilities attribute set correctly.' The task definition is generated dynamically during the build stage and uses the 'FARGATE' launch type. The error occurs only when a new task definition revision is created. You suspect the issue is related to how the task definition is generated. Upon reviewing the buildspec, you see that the task definition JSON is created using environment variables for the image URI. What is the MOST likely cause and solution?

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

✓

The task definition JSON does not include the 'requiresCompatibilities' field with the value '["FARGATE"]'.

The 'requiresCompatibilities' attribute must be explicitly set to 'FARGATE' for Fargate tasks. Option A is incorrect because the error is about compatibilities, not execution role. Option C is incorrect because network mode should be 'awsvpc', but that is not the error. Option D is incorrect because CPU and memory values are required but would cause a different error.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The task definition is missing the 'executionRoleArn' field, which is required for Fargate.

    Why it's wrong here

    While the `executionRoleArn` is mandatory for Fargate tasks to pull container images from ECR and inject Secrets Manager secrets, its absence yields a runtime/initialization error (e.g., 'ResourceInitializationError' or 'CannotPullContainerError'), not an API validation failure about launch type compatibility. ECS enforces the ARN as a separate requirement during task execution, not during the RegisterTaskDefinition compatibility check. Therefore, although required, it is not the cause of the specific error described in this scenario.

  • ✓

    The task definition JSON does not include the 'requiresCompatibilities' field with the value '["FARGATE"]'.

    Why this is correct

    The `requiresCompatibilities` array must explicitly contain the value `"FARGATE"` so that ECS can verify the task definition is eligible to launch on Fargate. When this field is missing, any attempt to run the task with `launchType: FARGATE` produces an `InvalidParameterException` stating that the task definition is not compatible with the requested launch type. This field is an explicit declaration independent of networkMode, CPU, or memory, and is the exact missing piece that triggers the complaint about compatibility.

  • ✗

    The task definition specifies 'networkMode' as 'bridge', but Fargate requires 'awsvpc'.

    Why it's wrong here

    Fargate requires the task definition to use the `awsvpc` network mode, which gives each task its own elastic network interface; specifying `bridge` is only valid for EC2 launch types. If you try to launch such a task on Fargate, ECS raises a distinct `ClientException` saying the network mode is not supported for Fargate, rather than a missing compatibility-field error. The incompatibility is detected from the networkMode value itself, not from the absence of the `requiresCompatibilities` declaration.

  • ✗

    The task definition does not specify 'cpu' and 'memory' values, which are required for Fargate.

    Why it's wrong here

    CPU and memory are mandatory for Fargate because Fargate uses them to size the task's compute resources, and they must be declared at the task level. Omitting them produces a parameter validation error (e.g., 'Missing required parameter: cpu') when you call `RunTask` or `RegisterTaskDefinition`, not a launch type compatibility error. Thus, while they are required, their absence is a separate validation failure that occurs before the compatibility check involving `requiresCompatibilities`.

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.