AWS code deploy + bitbucket = failed (Error code HEALTH_CONSTRAINTS)

Question:

i’ve set up everything according to this article

https://aws.amazon.com/tw/blogs/apn/announcing-atlassian-bitbucket-support-for-aws-codedeploy/

Here is my env:

Instance (free tier with amazon linux)
– apache 2.4 installed

Security group
– only 22 (only my ip can access) and 80 port are opened

Iptables stopped

2 roles are set
– one for linking S3 <-> bitbucket
(attached custom policy)
– one role is for deployment group
(attached AWSCodeDeployRole policy)

The script tried to deploy is
https://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Linux.zip

Permission
/var/www/* is owned by ec2-user with 755 permission

Agent
service codedeploy-agent status =
The AWS CodeDeploy agent is running as PID 7200

Clues:
There are some zip file in my s3 bucket is uploaded for every deploy.

Error code: HEALTH_CONSTRAINTS

Anyone have an idea what the causes of deployment fail?

update1 After i re-launch the instance with iam profile, the application can be deployed. But it is still failed, when i click view events, there is log as follow:

Anyone what is the problem?

Answer:

The error code HEALTH_CONSTRAINTS means more instances failed than expected, which is defined by the deployment configuration.

For more information about why the deployment failed, on the deployment console https://region.console.aws.amazon.com/codedeploy/home?region=region#/deployments, you can click on the failed deploymentID, then it will redirect to the deployment details page, which contains all of the instances included in the specified deployment, and each line contains the instance’s lifecycle event. Then click on the ViewEvents, then if there is View Logs link, you can see the reason why this instance deployment failed.

If the console doesn’t have enough information for what you need, then the log on the instance can be found at less /var/log/aws/codedeploy-agent/codedeploy-agent.log. It contains the logs for most recent deployments.

Leave a Reply