1

I am trying to deploy my application using CodeDeploy but each time I encounter, Deployment Failed message with additional information attached that says : No hosts succeeded. (Error code: HEALTH_CONSTRAINTS).

I do not understand the reason for this. Following are the steps performed in order:

  • I launched instance with an IAM role that has 2 policies attached AmazonEC2FullAccess and AmazonS3FullAccess. The later policy suggests the following:

     { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": "*" } ] } 
  • While launching the instance from the aws console, I had specified the following in the advanced section : (as text selected)

    apt-get -y update apt-get -y install awscli apt-get -y install ruby2.0 cd /home/ubuntu aws s3 cp s3://aws-codedeploy-us-west-2/latest/install . --region us-west-2 chmod +x ./install ./install auto 
  • To push the code, I wrote:

    aws deploy push --application-name CDTestApp --s3-location s3://codedeploy-test-bucket-pc/PC.zip --source PulsarCloud/ 
  • To deploy, I wrote:

    aws deploy create-deployment --application-name CDTestApp --s3-location bucket=codedeploy-test-bucket-pc,key=PC.zip,bundleType zip,eTag="834db424710b1819b753444460dd361d" --deployment-group-name CDGroup --deployment-config-name CodeDeployDefault.OneAtATime --description MyTestApplication 
  • I got the deployment id in return.

  • After sometime, the deployment turns into a failure!

  • appspec.yml:

    version: 0.0 os: linux files: - source: /sdk/js/index.html destination: /var/www/html hooks: BeforeInstall: - location: /installerassets/installer.sh timeout: 6000 runas: root 

What could be the reason for this?

When I logged into the machine and entered:

sudo service codedeploy-agent status 

I got : codedeploy-agent: unrecognized service

But then I tried to re-install it using the steps here. The service is running, but cannot deploy the code.

1
  • Is the agent running or not? Your last few statements are unclear. Did you get sudo service codedeploy-agent status to work or not? Commented May 17, 2016 at 12:57

2 Answers 2

2

a couple of things to point out:

  • (Just for sanity checking purpose), the role posted only has s3, but not ec2?
  • Is codedeploy.amazonaws.com included in the Trust Relationship of the role?
  • To install the agent, sudo ./install auto should be used

The fact that codedeploy-agent is not recognized means that the agent is not installed. This is likely due to sudo is not used.

To explain the error code you saw: HEALTH_CONSTRAINT breached means that the default one by one deployment config is used. When the deployment failed for the first instance, the minimal healthy instance limit (which is 1) is breached, hence, the deployment would fail.

Sign up to request clarification or add additional context in comments.

Comments

0

Also, after confirming codedeploy agent is installed, make sure
1. EC2 instance has permissions to fetch data from the s3 bucket where revision is pushed
2. Codedeploy service role has following policy attached as well :

 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:DescribeInstanceStatus", "tag:GetTags", "tag:GetResources" ], "Resource": "*" } ] } 

3. Tagging EC2 instance properly and providing same key-value pair in codedeploy

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.