DOP-C02 Practice Question 21: CodeDeploy ApplicationStop Previous Revision
AWS Certified DevOps Engineer – Professional (DOP-C02) · Test 3 · question 1 of 10
A team deploys a web application to an Amazon EC2 fleet with AWS CodeDeploy in-place deployments. During an incident, an engineer manually cleaned up disk space on a subset of the instances and deleted files under the CodeDeploy deployment root directory. Every deployment since then fails on exactly those instances during the ApplicationStop lifecycle event with "Script does not exist at specified location", even though the new revision bundle contains the script and the same revision deploys successfully to every other instance in the deployment group.
What explains the failure, and what is the most direct way to get deployments working again?
Show answer and explanation
Answer:
ApplicationStop fires before the new revision is even downloaded, so it cannot use the new revision's files. The CodeDeploy documentation is explicit: "The AppSpec file and scripts used for this deployment lifecycle event are from the previous successfully deployed application revision." The agent finds that revision through the {{deployment-group-id}}_last_successful_install file under the deployment root. Deleting files there leaves a pointer to scripts that no longer exist, so the hook fails on those instances and only those instances. Creating the deployment with the option to ignore ApplicationStop failures lets the deployment get past the stale revision; once it succeeds, the newly installed revision becomes the "last successful" one and future ApplicationStop hooks come from it.
Option A blames the new revision, but the new revision's AppSpec file is not consulted at ApplicationStop at all, which is also why the identical bundle deploys cleanly to the untouched instances. Fixing a path there changes nothing for this event.
Option B misreads the symptom. An agent version mismatch would fail consistently across the deployment group and would not produce a missing-file error tied to the instances an engineer cleaned up by hand.
Option D addresses what happens *after* a failure, not the failure. Automatic rollback redeploys the last known good revision, the very revision whose scripts are missing, so the rollback would hit the same ApplicationStop problem. It never changes which revision supplies the hook.
Reference: AppSpec 'hooks' section