Courseiva
SDLC AutomationhardMultiple ChoiceObjective-mapped

DOP-C02 SDLC Automation Practice Question

You are a DevOps engineer at a company that runs a critical web application on Amazon EC2 instances behind an Application Load Balancer (ALB). The application is deployed using AWS CodeDeploy with an in-place deployment strategy. The deployment group contains 10 EC2 instances in an Auto Scaling group. Recently, a deployment failed with the error 'The overall deployment failed because too many individual instances failed deployment.' You check the CodeDeploy agent logs on one of the failed instances and see the error 'Script at /opt/codedeploy-agent/deployment-root/deployment-logs/scripts/application_start.sh failed with exit code 1.' The application_start.sh script is part of the AppSpec file. The script attempts to restart the web server. You notice that the script uses a path that exists only on some instances. What should you do to resolve this issue and prevent future failures?

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 application_start.sh script to check for the existence of the path before running the restart command.

The error occurs because the application_start.sh script attempts to restart the web server using a path that does not exist on all instances. This is a script logic issue, not a timeout or agent issue. The best solution is to modify the script to check for the existence of the path before executing the restart command, making the script robust. Option A is incorrect because increasing the timeout does not fix the script failure. Option C is incorrect because removing the script would bypass necessary post-installation steps. Option D is incorrect because reinstalling the agent does not address the script path issue.

Answer analysis

Option-by-option breakdown

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

  • Increase the deployment timeout in CodeDeploy.

    Why it's wrong here

    Increasing the CodeDeploy deployment timeout does not fix the problem because the application_start.sh hook fails immediately with a non-zero exit status, not because it exceeds a time limit. The timeout only sets the maximum duration that CodeDeploy waits for a deployment to complete; it does not retry or ignore a failed lifecycle script. This change would simply delay the eventual failure while the script still errors out on the missing path.

  • Modify the application_start.sh script to check for the existence of the path before running the restart command.

    Why this is correct

    Modifying application_start.sh to check for the missing path before invoking the restart command directly addresses the root cause: the restart command (e.g., systemctl restart) is failing because its target binary or configuration file does not exist, causing a non-zero exit that fails the lifecycle hook. Adding a guard such as `if [ -f /path/to/binary ]; then systemctl restart app; else exit 1; fi` ensures the script handles missing dependencies gracefully and only attempts the restart when the prerequisite is actually present on the instance. This also makes the script more robust and idempotent so retries won't fail on the same missing file.

  • Remove the application_start.sh script from the AppSpec file.

    Why it's wrong here

    Removing application_start.sh from the AppSpec file would eliminate the immediate failure, but it would also prevent the application from being started during the deployment, leaving the service down and defeating the purpose of the ApplicationStart lifecycle event. This action masks the underlying bug rather than fixing it, and it could lead to a successful deployment with an unusable application, which is worse than a failed deployment that alerts the team. The correct approach is to repair the script logic, not to remove the hook entirely.

  • Reinstall the CodeDeploy agent on all instances.

    Why it's wrong here

    Reinstalling the CodeDeploy agent on all instances is unnecessary because the agent itself is functioning correctly; the evidence shows it is executing application_start.sh and relaying its non-zero exit status. The failure originates in the user-authored script, not in the agent's execution framework, and reinstalling will not change the absence of the path or the script's logic. This action would consume time and resources without affecting the actual root cause, and it would not prevent the same script failure from recurring after redeployment.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

One of 1,013 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.