0

首先,我知道有一个类似的问题(AWS CodePipeline with ECS Blue/Green deployment failed with internal error),但是回答它的人没有提供足够的细节。

根据这个答案:https : //superuser.com/questions/1388058/getting-internal-error-in-aws-code-pipeline-while-deploying-to-ecs ..我已经阅读了aws指南:https: //docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#constraints ... 确保所有“必填”字段都在我的taskdef.json中(如下

至于我的管道(构建)buildSpec ...

    - printf '{"ImageURI":"%s"}' $ECR_REPO_URI:demo > imageDetail.json
          - echo Build completed on `date`

  artifacts:
    files:
      - imageDetail.json

管道 构建阶段设置很简单,我只是将 BuildArtifact 设置为输出。所以我可以从管道 部署阶段引用 imageDetail.json 。

至于我的管道(部署)AppSpec ...

version: 0.0

Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: <TASK_DEFINITION>
        LoadBalancerInfo:
          ContainerName: "pipeline_demo"
          ContainerPort: 80
        PlatformVersion: "LATEST"

管道 部署阶段设置如下: 输入工件:BuildArtifact、SourceArtifact ;然后:

  • Amazon ECS 任务定义:SourceArtifact “taskdef.json”
  • AWS CodeDeploy AppSpec 文件:SourceArtifact “taskdef.json”

动态更新任务定义镜像:BuildArtifact

  • 任务定义中的占位符文本:IMAGE1_NAME

(..其中一些来自本指南:https ://medium.com/@shashank070/in-my-previous-blog-i-have-explained-how-to-do-initial-checks-like-code -review-code-build-cddcc21afd9f

..和taskdef:

{
  "family": "devops-platform-ecs-task-def",
  "type": "AWS::ECS::TaskDefinition",
  "properties": {
    "containerDefinitions": [
      {
        "name": "pipeline_demo",
        "image": "<IMAGE1_NAME>",
        "cpu": "1024",
        "memory": "1024",
        "essential": true,
        "portMappings": [
          {
            "hostPort": 0,
            "protocol": "tcp",
            "containerPort": 80
          }
        ]
      }
    ],
    "ExecutionRoleArn": "arn:aws:iam::xxxxxx:role/devops_codepipeline",

    "NetworkMode": "null",
    "PlacementConstraints": [
        "type": "memberOf",
        "expression": ""
    ],
    "ProxyConfiguration": {
      "type": "APPMESH",
      "containerName": "",
      "properties": [
          {
              "name": "",
              "value": ""
          }
      ]
    },
    "RequiresCompatibilities": [
      "EC2"
    ],
    "Tags": [
      {
        "key": "",
        "value": ""
      }
    ],
    "TaskRoleArn": "",
    "Volumes": [
        {
            "name": "",
            "host": {
                "sourcePath": ""
            },
            "dockerVolumeConfiguration": {
                "scope": "task",
                "autoprovision": true,
                "driver": "",
                "driverOpts": {
                    "KeyName": ""
                },
                "labels": {
                    "KeyName": ""
                }
            }
        }
    ]
  }
}

尽管如此,我仍然得到错误...... 在此处输入图像描述

任何帮助将非常感激!

4

2 回答 2

1

您的任务定义无效。快速浏览一下,我可以看到以下无效属性:

"type": "AWS::ECS::TaskDefinition",

请在此处查看示例任务定义 [1]。另外,我建议从 taskdef 中删除任何无关的部分,这样它们就不会以任何方式干扰。

[1] https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html

于 2019-12-08T02:14:41.080 回答
0

我实际上发现包含另一个策略AWSCodeDeployRoleForECS解决了这个问题。它在 CLI 的 aws 指南中引用(到目前为止,我们一直在通过控制台进行管理,因此我只是偶然发现了这一点)创建服务角色(CLI)。包含该策略后,管道已超越列出的问题,但遇到了另一个“无效的配置操作;容器列表不能为空”。- 你的答案可以解决哪个?尽管如此,至少我有一个更有意义的错误要处理。

于 2019-12-09T11:05:01.660 回答