1

I am new to AWS and I am trying to deploy using AWS CodeDeploy from Github. For that, I created my instance named CodeDeployDemo and attached the role and policy to the instance.

Policy ARN    arn:aws:iam::378939197253:policy/CE2CodeDeploy9

My policy is:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Action": [
            "s3:Get*",
            "s3:List*"
        ],
        "Effect": "Allow",
        "Resource": "*"
    }
]

}

and also attached policy named AmazonEC2RoleforAWSCodeDeploy I also installed CodeDeploy agent for my ubuntu step by step as following:

$chmod 400 Code1.pem
$ssh -i "Code1.pem" [email protected]
$sudo apt-get update
$sudo apt-get install awscli
$sudo apt-get install ruby2.0
$cd /home/ubuntu
$sudo aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
$sudo chmod +x ./install
$sudo ./install auto

and then I create my application and deploy from GitHub to CodeDeploy using CodeDeployDefault.OneAtATime

But at final stage it shows following error:

Deployment failed: Because too many individual instances failed deployment,
too few healthy instances are available for deployment, 
or some instances in your deployment group are experiencing problems.
(Error code: HEALTH_CONSTRAINTS)

NOTE: My only one instance is running when my deployment is running.I stopped other instances. Please help me to find solution for this. THANKS IN ADVANCE.!!

1 Answer 1

2

This happens because the codeDeploy checks health of the ec2 instances by hitting instances. Before deployment, you need to run below bash script on the instances and check if the script worked. httpd service must be started. Reboot the instance.

    #!/bin/bash
    sudo su  
    apt-get update -y
    apt-get install apache2 -y
    apt-get install ruby2.0
    apt-get install awscli
    cd ~
    aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
    chmod +x ./install
    ./install auto
    echo 'hello world' > /var/www/html/index.html
    hostname >> /var/www/html/index.html
    update-rc.d apache2 defaults
    service apache2 start
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.