AWS CodeDeploy无故失败

时间:2019-12-03 03:07:08

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

我正在尝试使用AWS CodeDeploy将Java war文件部署到EC2实例。

我已经在这场战争的根源中添加了一个appspec.yml,内容如下:

version: 0.0
os: linux 
files:
  - source: /
    destination:  /var/scwcd/scwcd

我还创建了一个EC2实例,codeDeploy应用程序可以看到此Ec2实例。 我将此战争文件手动上传到我的S3存储桶,并将codeDeploy源设置为S3文件。 我还为CodeDeploy添加了足够的权限来访问S3和EC2实例。

但是部署始终会失败,并显示以下消息:

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

我检查了部署事件列表,发现每个动作都被跳过而没有错误代码:

enter image description here

我还检查了EC2实例,发现目标文件夹/ var / scwcd不存在。

有人知道我错过了吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您是否已在EC2实例上安装了CodeDeploy代理[1]?跳过所有事件通常意味着代理未调用CodeDeploy服务端点[2]。

您可以在实例首次启动时使用EC2 UserData中的以下命令来安装代理程序:

Amazon Linux / RHEL

    // Initialize the GraphServiceClient.
    GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient();

    var subRequest = client.Subscriptions.Request();
    var result = subRequest.GetAsync().Result;

    return Ok(result);

Ubuntu

    {
        "resource": "users/b4f9f62f-0993-4288-8efa-387cff59de9d/events",
        "changeType": "updated",
        "notificationUrl": "https://cc3949e3.ngrok.io/Communication/Listen",
        "expirationDateTime": "2019-12-04T10:08:08.7432958+00:00",
        "applicationId": "bd1f8386-f148-45ee-957d-90c18bb1a6e3",
        "creatorId": "35636f28-5598-4772-9d99-19bf55de60ac",
        "id": "1587894f-4be3-4e58-8117-dd346059911d",
        "@odata.type": "microsoft.graph.subscription"
    }

[1] https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html

[2] https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-skipped-lifecycle-events