我的 Bitbucket 管道在 CodeDeploy 步骤(部署到 EC2 实例)上失败

问题描述 投票:0回答:1

这里是 AWS 新手。

我正在开发我的第一个 Bitbucket 管道以部署到 AWS。它分为三个步骤:

  1. 压缩项目文件
  2. 上传到 AWS S3 存储桶
  3. 使用 CodeDeploy 将应用程序文件部署到 EC2 实例

这是我最近的跑步:

enter image description here

事实上,我认为这是进步!我第一次运行这个时,我自己在 6 分半钟左右停止了它,因为它似乎挂在这条线上:

aws deploy wait deployment-successful --deployment-id d-V1OU4NNG8

这次它自己失败了,至少提供了一些诊断信息可供查看。

Status: Downloaded newer image for bitbucketpipelines/aws-code-deploy:0.2.10
INFO: Deploying app from revision.
aws deploy get-application-revision --application-name lightning-comm --revision revisionType=S3,s3Location={bucket=lightning-comm-codedeploy-deployment,bundleType=zip,key=lightning-comm-10-b614e62f}
{
    "applicationName": "lightning-comm", 
    "revisionInfo": {
        "lastUsedTime": 1726775747.124, 
        "firstUsedTime": 1726775747.124, 
        "registerTime": 1726775712.153, 
        "description": "Application revision registered by Deployment ID: d-K49RJELG8", 
        "deploymentGroups": []
    }, 
    "revision": {
        "revisionType": "S3", 
        "s3Location": {
            "bundleType": "zip", 
            "bucket": "lightning-comm-codedeploy-deployment", 
            "key": "lightning-comm-10-b614e62f"
        }
    }
}
aws deploy create-deployment --application-name lightning-comm --deployment-group deployment --revision revisionType=S3,s3Location={bucket=lightning-comm-codedeploy-deployment,bundleType=zip,key=lightning-comm-10-b614e62f} --ignore-application-stop-failures --file-exists-behavior OVERWRITE
{
    "deploymentId": "d-V1OU4NNG8"
}
INFO: Deployment created with id d-V1OU4NNG8.
INFO: Waiting for deployment to complete.
aws deploy wait deployment-successful --deployment-id d-V1OU4NNG8
Waiter DeploymentSuccessful failed: Waiter encountered a terminal failure state
ERROR: Deployment failed. Fetching deployment information...
aws deploy get-deployment --deployment-id d-V1OU4NNG8
{
    "deploymentInfo": {
        "applicationName": "lightning-comm", 
        "status": "Failed", 
        "deploymentOverview": {
            "Skipped": 0, 
            "Succeeded": 0, 
            "Failed": 1, 
            "Ready": 0, 
            "InProgress": 0, 
            "Pending": 0
        }, 
        "computePlatform": "Server", 
        "deploymentConfigName": "CodeDeployDefault.AllAtOnce", 
        "creator": "user", 
        "errorInformation": {
            "message": "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.", 
            "code": "HEALTH_CONSTRAINTS"
        }, 
        "fileExistsBehavior": "OVERWRITE", 
        "deploymentId": "d-V1OU4NNG8", 
        "deploymentStatusMessages": [], 
        "ignoreApplicationStopFailures": true, 
        "deploymentStyle": {
            "deploymentType": "IN_PLACE", 
            "deploymentOption": "WITHOUT_TRAFFIC_CONTROL"
        }, 
        "updateOutdatedInstancesOnly": false, 
        "rollbackInfo": {}, 
        "instanceTerminationWaitTimeStarted": false, 
        "deploymentGroupName": "deployment", 
        "createTime": 1726780175.753, 
        "completeTime": 1726780481.716, 
        "revision": {
            "revisionType": "S3", 
            "s3Location": {
                "bundleType": "zip", 
                "bucket": "lightning-comm-codedeploy-deployment", 
                "key": "lightning-comm-10-b614e62f"
            }
        }
    }
}

这似乎是相关信息:

        "errorInformation": {
            "message": "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.", 
            "code": "HEALTH_CONSTRAINTS"
        }

好的,“失败的单个实例太多”、“运行状况良好的实例太少”——我只部署到一个 EC2 实例,而该实例失败了。无论出现什么问题,它都不会很快失败,大约需要 5 分钟以上才会失败。我想无论出现什么问题,或者是否需要检查其他诊断,这些都将在 AWS 端找到。我是 AWS 的新手。如果您能为我提供一些指导,告诉我在 AWS 端寻找什么以查找其他诊断,或者在哪里查找可能的错误配置,这将非常有帮助。谢谢!

amazon-web-services amazon-ec2 bitbucket-pipelines aws-code-deploy
1个回答
0
投票

我想通了。我在部署文件夹结构的根部丢失了文件 appspec.yml。

我添加了这个appspec.yml(它是简单的,我正在一步一步进行):

version: 0.0
os: linux
files:
  - source: /
    destination: /api
hooks:

成功!

Pipeline Status

如果您想了解更多信息,请在此处定义 AppSpec:

https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html#appspec-reference-ecs

© www.soinside.com 2019 - 2024. All rights reserved.