部署失败 - CodeDeploy

时间:2017-01-27 07:59:25

标签: amazon-web-services amazon-ec2 amazon-iam aws-code-deploy

昨天我能够成功地将代码部署到ec2实例,突然在今天部署时显示出奇怪的错误。

ERROR:

  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)

然后我在ec2实例中的日志文件中发现了问题,如下所示

 "InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Missing credentials - please check if this instance was started with an IAM instance profile"

所以我检查了我的ec2实例是否通过如下所示正确地扮演了角色

 curl http://169.254.169.254/latest/meta-data/iam/security-credentials/CodeDeployInstanceRole 

显示输出

 {
 "Code" : "AssumeRoleUnauthorizedAccess",
 "Message" : "EC2 cannot assume the role CodeDeployInstanceRole. Please see documentation at http://docs.amazonwebservices.com/IAM/latest/UserGuide/RolesTroubleshooting.html.",
 "LastUpdated" : "2017-01-27T06:23:24Z"

 }

我做了两个实例角色CodeDeployInstance Role(AmazonEC2RoleforAWSCodeDeploy策略)和CodeDeployServiceRole(AWSCodeDeployRole策略),它们已正确设置。我在启动时向ec2实例添加了实例角色。但不确定为什么我的ec2实例无法承担实例角色。

1 个答案:

答案 0 :(得分:0)

例如,配置文件IAM角色,您希望在信任关系中确保它信任ec2端点。有人可能会意外删除该信任关系。