我是 Amazon Code Deploy 的新手。部署时出现错误
部署失败
没有成功的主机
我检查了我的 Linux 机器上的服务代码 deploy-agent 并且它正在运行 我该如何解决这个问题?
我是 Amazon Code Deploy 的新手。部署时出现错误
部署失败
没有成功的主机
我检查了我的 Linux 机器上的服务代码 deploy-agent 并且它正在运行 我该如何解决这个问题?
大多数情况下,由于实例和 CodeDeploy 服务上的 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": "*"
}
]
}
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
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
正如 BrunoLevy 所说,我们将需要有关您尝试进行的部署的更多信息。
但是,作为调试的起点,您可以从部署页面观察部署在哪一步失败
您还可以查看主机上的主机代理日志文件 (/var/log/aws/codedeploy-agent/codedeploy-agent.log)。该文件包含有关部署的信息。