AWS Deployment Failed due to “HEALTH_CONSTRAINTS”

我是研究僧i 提交于 2019-12-07 14:11:50

问题


I am working on a scenario, where I need to push the code from a GIT repository to AWS Instance. To achieve this I am using AWS CodeDeploy feature. But in the final step of the process to deploy the code, I am receiving the below error.

Deployment Failed The overall 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:


You can see this error if the EC2 instance does not have the correct IAM role. Create an IAM role with the policy "AmazonEC2RoleforAWSCodeDeploy". You can't add an IAM role to an existing instance, so you'll have to launch a fresh one.

Also make sure you've installed the CodeDeploy agent for the correct region, e.g. for us-east-1:

apt-get -y install awscli ruby2.0
aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
chmod +x ./install
./install auto

http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html




回答2:


I repeatedly get same error from CodeDeploy tool, if I forget to install CodeDeploy agent to the instance. Just in case here is the link to the documentation: http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-run-agent-install.html




回答3:


Just to add to @spro/@mathieu-m-gosselin 's answer, even though aws now allows to attach/replace an IAM role on a running instance but it is not enough for this use case , you have to reboot the instance after you attach/replace a new IAM role.




回答4:


The immediate reason you get that error is when CodeDeploy cannot continue the deployment as too many instances is unhealthy. The "minimumHealthyHosts" plays a part in determining the exact number. You can check that parameter [1][2].

Having said that, for a start, it is easier if set that value to low (i.e. almost 0). Or select the "AllAtOnce" deployment config.

[1] http://docs.aws.amazon.com/cli/latest/reference/deploy/get-deployment-config.html

[2] http://docs.aws.amazon.com/codedeploy/latest/userguide/host-health.html



来源:https://stackoverflow.com/questions/39143191/aws-deployment-failed-due-to-health-constraints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!