If I perform a deployment with AWS CodeDeploy that has an incorrect (failing) script for the ApplicationStop hook, it seems that I cannot do new deployments at all because the ApplicationStop hook from the previous (failed) deployment is run instead of the new one, and it just constantly fails.
Beyond deleting and recreating the application and/or deployment group, is there any way to tell code deploy to do a deployment as if it was a completely new deployment, and not run the ApplicationStop hook?
Relatedly, is it possible to ignore errors in ApplicationStop?
Yes it is possible to ignore errors in ApplicationStop. The CreateDeployment API call has a flag “ignoreApplicationStopFailures” [1] which can be used in this case.
If the cause of the failure is a script from the last successful deployment that will never run successfully, create a new deployment (you can copy a deployment as well) and specify that the ApplicationStop failures should be ignored. You can do this in two ways:
Use the AWS CodeDeploy console to create a deployment. On the Create deployment page, under ApplicationStop lifecycle event failure, choose Don't fail the deployment to an instance if this lifecycle event on the instance fails.
Use the AWS CLI to call the create-deployment command and include the --ignore-application-stop-failures option.
When you deploy the application revision again, the deployment will continue even if the ApplicationStop lifecycle script fails. If the new revision includes fixed scripts for the ApplicationStop lifecycle event, future deployments can succeed without applying this fix.
References: