错误:AWS CodeDeploy中的HEALTH_CONSTRAINTS在从Github部署到AWS CodeDeploy时

时间:2017-01-23 05:54:02

标签: amazon-web-services amazon-s3

我是AWS新手,我正在尝试使用Github的AWS CodeDeploy进行部署。 为此,我创建了名为CodeDeployDemo的实例,并将角色和策略附加到实例。

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

我的政策是:

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

}

以及名为AmazonEC2RoleforAWSCodeDeploy的附加政策 我还为我的ubuntu逐步安装了CodeDeploy代理,如下所示:

$chmod 400 Code1.pem
$ssh -i "Code1.pem" ubuntu@54.183.22.255
$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

然后我创建我的应用程序并使用CodeDeployDefault.OneAtATime

从GitHub部署到CodeDeploy

但在最后阶段,它显示以下错误:

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)

注意:我的部署正在运行时,我的唯一一个实例正在运行。我停止了其他实例。 请帮我找到解决方案。感谢提前。!!

1 个答案:

答案 0 :(得分:2)

这是因为codeDeploy通过命中实例来检查ec2实例的运行状况。在部署之前,您需要在实例上运行以下bash脚本并检查脚本是否有效。必须启动httpd服务。重新启动实例。

    #!/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