DOP-C02 Configuration Management and IaC Practice Question
A company uses AWS CodeDeploy for application deployments to EC2 instances. The team recently noticed that deployments are failing because some instances do not have the CodeDeploy agent installed. Which configuration management approach should the team implement to ensure the CodeDeploy agent is installed and running on all instances before deployment?
⚠ Common exam trap
It's easy for candidates to assume CodeDeploy can automatically install its own agent on instances (Option D), but AWS CodeDeploy has no such built-in capability; the agent must be provisioned independently through AMI, user data, or a configuration management tool like AWS Systems Manager or Chef.
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
✓
Create a custom AMI with the CodeDeploy agent pre-installed, or use a user data script to install the agent at launch.
It ensures the CodeDeploy agent is present on every EC2 instance from the moment it is launched, either by baking the agent into a custom AMI or by installing it via a user data script. This approach aligns with immutable infrastructure and configuration management best practices, preventing deployment failures caused by missing agents. AWS CodeDeploy requires the agent to be installed and running on target instances before any deployment can proceed.
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 an AWS Config rule to detect instances without the agent and trigger a Lambda function to install it.
Why it's wrong here
An AWS Config rule that detects missing CodeDeploy agents and triggers a Lambda function is a reactive, post-detection remediation pattern. By the time AWS Config evaluates the rule (typically on a periodic schedule or after configuration changes) and Lambda runs to install the agent, a deployment may have already been attempted and failed, because deployments do not wait for remediation. Additionally, this approach requires creating and maintaining custom Lambda permissions, IAM roles, and error handling for install failures, adding operational overhead without guaranteeing the agent is present before the next deployment starts.
- ✗
Use the CodeDeploy deployment configuration to skip instances that do not have the agent.
Why it's wrong here
A deployment configuration in CodeDeploy controls failure thresholds (e.g., how many instances can fail before the deployment stops) and traffic shifting behavior; it is not a mechanism for filtering instances based on agent presence. If you configure a deployment to skip instances without the agent, those instances would be excluded from the deployment entirely, leaving them running outdated or inconsistent application versions. CodeDeploy does not have a built-in setting to 'skip and install' — skipping merely bypasses the instance, silently creating configuration drift and defeating the purpose of a uniform deployment.
- ✓
Create a custom AMI with the CodeDeploy agent pre-installed, or use a user data script to install the agent at launch.
Why this is correct
Pre-installing the CodeDeploy agent in a custom AMI (or bootstrapping it via user-data at instance launch) ensures the agent is running before the instance ever joins a deployment group. Because the agent is already present, CodeDeploy's deployment workflow can immediately begin pulling the AppSpec file and application revision from Amazon S3 or GitHub without waiting for an installation step. This proactive approach also avoids the time-of-installation risk where a deployment starts before a scripted agent installation completes, and it minimizes the chance of an instance being skipped or failing due to a missing agent.
- ✗
Configure the CodeDeploy deployment group to automatically install the agent on new instances.
Why it's wrong here
CodeDeploy does not have a feature to automatically install the agent on instances as part of a deployment group configuration; the service assumes the agent is already installed and running on the target instances. When you register an on-premises instance or launch an EC2 instance in a deployment group, CodeDeploy expects the agent to be present to poll for deployment commands. If the agent is missing, the instance is simply marked as a failed deployment target, and the deployment may roll back — the service will not push an agent installer to the instance on its own.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 251 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 →
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.