A developer is performing an in-place deployment of a new application revision to a fleet of Amazon EC2 instances using AWS CodeDeploy. The developer updated a cleanup script named 'stop-server.sh' in the new revision and referenced it in the 'ApplicationStop' lifecycle hook of the 'appspec.yml' file. However, the deployment fails during the 'ApplicationStop' phase. Investigation reveals that the 'stop-server.sh' script currently residing on the instances (from the previous deployment) has a syntax error that causes it to exit with a non-zero status, whereas the updated script in the new deployment bundle has this error fixed. Which of the following explains why the deployment failed and how the developer can successfully deploy the new application revision?
- ACodeDeploy executes the 'ApplicationStop' hook using the script from the new deployment bundle. The deployment failed because the new bundle was not yet downloaded, which the developer must resolve by changing the hook in the appspec.yml file to 'BeforeInstall'.
- BCodeDeploy failed to run the script because the EC2 instance profile lacks the required trust policy to assume the CodeDeploy service role. The developer must update the IAM role trust policy to allow the EC2 service principal to assume the CodeDeploy role.
- CodeDeploy executes the 'ApplicationStop' hook using the script from the previously deployed revision on the instances. The developer can bypass this failure by redeploying the new revision with the ignore application stop failures option enabled.Answer
- DCodeDeploy failed to execute the script because the credentials required by 'stop-server.sh' were stored in Systems Manager Parameter Store rather than Secrets Manager. The developer must migrate the parameters to AWS Secrets Manager to allow script execution.