设置CodePipeline-部署步骤的状态为失败 [英] Setup CodePipeline - Deploy step has a status of failed
问题描述
在按照
如果我单击失败下的详细信息
如果我单击链接到执行详细信息
部署失败,因为未找到
部署组的实例。检查您的部署组设置,以确保
用于您的Amazon EC2实例或Auto Scaling组的标签
正确地标识了要部署到的实例,然后再次尝试
。
这很可能是由于位置问题所致-
- IAM-不需要选择区域。
- S3 -不需要选择区域。
- LightSail实例-伦敦,A区(eu-west-2a)
- CodeDeploy应用程序-弗吉尼亚州( us-east-1)
- CodeDeploy管道-伦敦A区(eu-west-2a)
因此,我去了CodeDeploy,删除了北弗吉尼亚州的应用程序,并在伦敦的部署组创建了一个应用程序。然后,在伦敦在那里创建新管道。
这次部署也失败了,但是原因不同
整个部署失败,因为有太多单独的实例
部署失败,太少的正常实例无法用于
部署,或者部署组中的某些实例
遇到问题。
为了解决这个问题,我ve删除了两个管道并创建了一个新管道。由于必须更改角色,因此我使用了 AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline
,但这在创建管道时遇到了麻烦
无法创建角色
AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline
< a href = https://i.stack.imgur.com/wUOSX.png rel = nofollow noreferrer>
因此,我将其更改为 AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoP
。然后,这使我陷入另一个问题
名为
的策略AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline
已经存在。不允许重复的名称。
因此,我回过头来,将管道名称更改为 CodeDeployLightsailDemoPi
,将角色名称更改为 AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPi
。
这使我陷入困境
整个部署失败,因为单个实例过多b部署失败,可用于
部署的正常实例太少,或者您的部署组中的某些实例
遇到问题。
我决定等待30分钟,并创建一个新管道,为其命名为 CodeDeployLightsailPipeline
和角色名 AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailPipelin
,但发生了同样的问题。
这是Deployment ID>中显示的信息。查看事件
根据
因此,我已经在其中创建了这两个文件夹
并重新开始部署
,但是它像以前一样失败了。
如何获得成功的部署状态?
Edit
到
When setting up CodeDeploy following this tutorial, under the last step of Setup CodePipeline
If I click in Details under Failed
If I click in Link to execution details
The deployment failed because no instances were found for your deployment group. Check your deployment group settings to make sure the tags for your Amazon EC2 instances or Auto Scaling groups correctly identify the instances you want to deploy to, and then try again.
This was most likely due to a problem in locations - sometimes it was used N. Virginia and other times London.
- IAM - does not require region selection.
- S3 - does not require region selection.
- LightSail instance - London, Zone A (eu-west-2a)
- CodeDeploy application - N. Virginia (us-east-1)
- CodeDeploy pipeline - London, Zone A (eu-west-2a)
So, I went to CodeDeploy, deleted the application in N. Virginia and created one with its deployment group in London. Then, created a new pipeline there in London.
The deployment failed this time too but with a different reason
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.
In order to fix that, I've deleted both pipelines and created a new one. Since I had to change the role, I used AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline
but this got me into troubles in the moment of Creating the pipeline
Could not create role AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline
So, I changed it to AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoP
. Then, this got me into another problem
A policy called AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPipeline already exists. Duplicate names are not allowed.
So, I went back and changed the Pipeline name to CodeDeployLightsailDemoPi
and the Role name to AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailDemoPi
.
This got me into the same
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.
I decided to wait 30 minutes and create a new pipeline giving it the name CodeDeployLightsailPipeline
and the role name AWSCodePipelineServiceRole-eu-west-2-CodeDeployLightsailPipelin
but the same problem happened.
This is what the information present in Deployment ID > View events
According to Marcin, I should have found the appspec.yml
version: 0.0
os: linux
files:
- source: /index.html
destination: /var/www/html/
hooks:
BeforeInstall:
- location: scripts/install_dependencies
timeout: 300
runas: root
- location: scripts/start_server
timeout: 300
runas: root
ApplicationStop:
- location: scripts/stop_server
timeout: 300
runas: root
In it, it mentions destination: /var/www/html/
but in the instance there's no such /var/www/html
path
So, I've created these two folders in it
and restarted the deployment
but the it failed just like before.
How can I get the Deploy status to succeeded?
Edit
According to the documentation, this error code shows HEALTH_CONSTRAINTS. So, I'm now reading:
Based on the comments:
In an attempt to reproduce the issue, I deployed the application CodeDeployGitHubDemo used by the OP on my own Amazon Linux 2 instances with CodeDeploy. I could verified that the CodeDeployGitHubDemo
and its appspec.yml
files are correct and work as expected.
Since the OP is using CodePipline (CP), it was suggest to go one step back and focus on deployment using CodeDeploy (CD) only, without added complexity of using combination of CP + CD. This allows to focus only on CD issues and should simplify finding the root cause of the problems. Once standalone CD deployment works, the next step is to work on incorporating CP in the deployment process, knowing exactly how CD should be setup to work.
More specifically, this is what was done
In IAM console at https://console.aws.amazon.com/iam/
1.1. Deleted one role (CodeDeployServiceRole).
1.2. Created a service role.
In S3 console at https://console.aws.amazon.com/s3/
2.1. Emptied and deleted one bucket (tiagocodedeploylightsailbucket).
2.2. Created a new bucket in EU London (eu-west-2).
Back into the IAM console at https://console.aws.amazon.com/iam/
3.1. Deleted one policy (CodeDeployS3BucketPolicy).
3.2. Created a new policy.
Stay in the IAM console at https://console.aws.amazon.com/iam/
4.1. Delete one user (LightSailCodeDeployUser)
4.2. Created a new user (Note that it needs to have a different name or else would get this problem).
Navigate to the Lightsail home page at https://lightsail.aws.amazon.com/
5.1. Deleted previous instance (codedeploy).
5.2. Created one new instance with Amazon Linux (Amazon_Linux_1) (Note that if used Amazon Linux 2 then would reach this problem),
using the script
mkdir /etc/codedeploy-agent/
mkdir /etc/codedeploy-agent/conf
cat <<EOT >> /etc/codedeploy-agent/conf/codedeploy.onpremises.yml
---
aws_access_key_id: ACCESS_KEY
aws_secret_access_key: SECRET_KEY
iam_user_arn: arn:aws:iam::525221857828:user/GeneralUser
region: eu-west-2
EOT
wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
SSH in both instances
6.1. Verify if codedeploy-agent is running (
sudo service codedeploy-agent status
)In PowerShell with AWS CLI on your local machine
7.1.
Run
aws deploy register-on-premises-instance --instance-name Amazon_Linux_1 --iam-user-arn arn:aws:iam::525221857828:user/GeneralUser --region eu-west-2
Then
aws deploy add-tags-to-on-premises-instances --instance-names Amazon_Linux_1 --tags Key=Name,Value=CodeDeployLightsailDemo --region eu-west-2
Then
aws deploy list-on-premises-instances --region eu-west-2
In the end, got as output
{
"instanceNames": [
"Amazon_Linux_1",
"codedeploy"
]
}
Navigate to the CodeDeploy console at https://eu-west-2.console.aws.amazon.com/codesuite/codedeploy/start?region=eu-west-2#
8.1. Delete the application (CodeDeployLightsailDemo).
8.2. Create a new application with a new deployment group (CodeDeployLightsailDemoDeploymentGroup).
Navigate to the CodePipeline console at https://eu-west-2.console.aws.amazon.com/codesuite/codepipeline/start?region=eu-west-2
9.1. Delete the pipeline (CodeDeployLightsailDemoPipeline).
9.2. Create a new pipeline using "New service role".
这篇关于设置CodePipeline-部署步骤的状态为失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!