我是Amazon Code Deploy的新手。我在部署
时遇到错误部署失败
没有主机成功
我检查了Linux机器上的服务代码deploy-agent,它正在运行 我该如何解决这个问题?
答案 0 :(得分:3)
大多数情况下,由于Instance和CodeDeploy Service上的IAM权限不足而导致出现此问题。您需要检查/var/log/aws/codedeploy-agent/codedeploy-agent.log文件以获取详细信息。同样在/etc/codedeploy-agent/conf/codedeployagent.yml
文件中,您可以设置:verbose: true
以获取日志文件中的更多信息。
这些是您需要更新的IAM政策:
// Policy Role for Code Deploy
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"autoscaling:PutLifecycleHook",
"autoscaling:DeleteLifecycleHook",
"autoscaling:RecordLifecycleActionHeartbeat",
"autoscaling:CompleteLifecycleAction",
"autoscaling:DescribeAutoscalingGroups",
"autoscaling:PutInstanceInStandby",
"autoscaling:PutInstanceInService",
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
// Policy Trust for Code Deploy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"codedeploy.us-west-2.amazonaws.com",
"codedeploy.us-east-1.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
// Instance Role for EC2 Instance
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:Get*",
"s3:List*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
答案 1 :(得分:0)
正如BrunoLevy所说,我们需要有关您尝试进行的部署的更多信息。
但是,作为调试的起点,您可以从部署页面中观察部署失败的步骤
您还可以查看主机上的Host Agent日志文件(/var/log/aws/codedeploy-agent/codedeploy-agent.log)。该文件包含有关部署的信息。
答案 2 :(得分:0)
这是因为codeDeploy通过命中实例来检查ec2实例的运行状况。在部署之前,您需要在实例上运行以下bash脚本并检查脚本是否有效。必须启动httpd服务。重新启动实例。
#!/bin/bash
sudo su
yum update -y
yum install httpd -y
yum install ruby
yum install aws-cli
cd ~
aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
chmod +x ./install auto
./install auto
echo 'hello world' > /var/www/html/index.html
hostname >> /var/www/html/index.html
chkconfig httpd on
service httpd start