Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeDeploy deployment failed at event ApplicationStop

I am trying to set up auto-deployment from GitHub to AWS, using EC2. I set Role with CodeDeployServiceRole auto policy

After following the Tutorial: Use AWS CodeDeploy to Deploy an Application from GitHub, my deployment fails at the ApplicationStop event, after trying for couple of minutes with error code HEALTH_CONSTRAINT. I'm not sure how to troubleshoot the issue/where to look.

like image 911
Aviad Cohen Avatar asked Mar 02 '23 23:03

Aviad Cohen


2 Answers

These are few hints of how you can navigate your way

  • Logs as mentioned in comments in /var/log/aws/codedeploy-agent

  • As AWS support recommend you can add for one time --ignore-application-stop-failures so it will skip that step in case it failed last time and see، because the application stop Lifecycle event uses the appspec file from the last successful build so if that one is corrupted somehow this step will fail in the following builds

  • (not recommended) you can delete the file, that CodeDeploy uses to keep track of the previous successful deployment in the following path /opt/codedeploy-agent/deployment-root/deployment-instructions/

like image 82
Kerolos William Avatar answered Mar 04 '23 12:03

Kerolos William


Check the latest logs at /var/log/aws/codedeploy-agent

If your deployment is failing at ApplicationStop event, then most likely the issue is your EC2 instance does not have the necessary permissions to get the artifacts from S3 bucket.

  1. Your EC2 instance must have an IAM role attached which gives it enough permissions to download the artifacts from S3 bucket
  2. Your EC2 must be started with an IAM role. So you may have to reboot your instance after attaching the role to it.

From your configuration, looks like you have provided permissions to CodeDeploy to perform certain actions on your EC2. You may want to check if your EC2 also has the necessary permissions to download packages from S3 bucket.

like image 45
ksaraiya Avatar answered Mar 04 '23 13:03

ksaraiya