Courseiva

DVA-C02 Development with AWS Services Practice Question

A company is using AWS CodePipeline to automate the deployment of a web application. The pipeline has three stages: Source (Amazon S3), Build (AWS CodeBuild), and Deploy (AWS CodeDeploy). The application is deployed to an Auto Scaling group of EC2 instances. Recently, a deployment failed because the CodeDeploy agent on one of the instances was not running. The developer wants to ensure that the CodeDeploy agent is always running on all instances. What is the MOST efficient 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

✓

Modify the Auto Scaling group's launch configuration to include a user data script that installs and starts the CodeDeploy agent.

The correct option is C: modifying the Auto Scaling group's launch configuration to include a user data script that installs and starts the CodeDeploy agent. This is the most efficient solution because user data scripts run automatically on every new EC2 instance at launch, ensuring the CodeDeploy agent is installed and started on all instances without manual intervention or ongoing monitoring. It directly addresses the root cause by making agent installation part of the instance provisioning process. Option A is inefficient because CloudTrail records API activity, not agent process status, and adding Lambda-based remediation is unnecessarily complex. Option B is not viable because CloudWatch cannot natively detect whether a local process like the CodeDeploy agent is running without custom metrics or agents. Option D could work but requires scheduled Run Command executions and doesn't guarantee the agent is present on newly launched instances before deployments occur.

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 CloudTrail to monitor the CodeDeploy agent status and trigger an AWS Lambda function to restart it.

    Why it's wrong here

    AWS CloudTrail records API calls and events made in your AWS account, providing an audit trail of actions taken by users or services. It does not directly monitor the operational status of agents running *within* EC2 instances, such as the CodeDeploy agent's process status. Therefore, CloudTrail cannot detect if the CodeDeploy agent has stopped running on an instance, making it unsuitable for triggering a restart based on internal agent status. This approach is fundamentally misaligned with CloudTrail's logging capabilities.

  • ✗

    Configure a CloudWatch alarm to detect when the CodeDeploy agent is not running and restart it automatically.

    Why it's wrong here

    While Amazon CloudWatch can monitor custom metrics, such as the CodeDeploy agent's process status if published from the instance, a CloudWatch alarm itself cannot directly restart an agent on an EC2 instance. An alarm can trigger actions like sending notifications or invoking an AWS Lambda function, which would then execute a restart command. However, the option states "restart it automatically" without specifying the necessary intermediary Lambda function, making it an incomplete and not a direct capability of the alarm itself.

  • ✓

    Modify the Auto Scaling group's launch configuration to include a user data script that installs and starts the CodeDeploy agent.

    Why this is correct

    Including a user data script in an Auto Scaling group's launch configuration or launch template is the most effective and proactive method. User data scripts execute automatically when an EC2 instance first launches, allowing for the installation and startup of necessary software, including the CodeDeploy agent. This ensures that every new instance provisioned by the Auto Scaling group is immediately ready to receive CodeDeploy deployments without manual intervention or reactive checks, making it a robust and scalable solution.

  • ✗

    Use AWS Systems Manager Run Command to run a script that checks and restarts the CodeDeploy agent on a schedule.

    Why it's wrong here

    AWS Systems Manager Run Command can execute scripts on EC2 instances, and it could be scheduled to periodically check and restart the CodeDeploy agent. However, this approach is reactive and less efficient than ensuring the agent is installed and started at instance launch. Relying on a scheduled check means there could be a delay between the agent stopping and its detection and restart, potentially causing deployment failures during that window. It adds overhead compared to a "set-and-forget" configuration at instance creation.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

This DVA-C02 question is part of Courseiva's 1,135-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 DVA-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 DVA-C02 exam.