2

我有一个我AWS ECS Task definition喜欢的 json 文件:

[
    {
      "name": "my-name",
      "image": "url",
      "cpu": 2,
      "dnsSearchDomains": null,
      "network_configuration":"awsvpc",
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 8080,
          "protocol": "tcp",
          "containerPort": 8080
        }
      ],
      "command": null,
      "linuxParameters": null,
      "environment": [],
      "resourceRequirements": null,
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": null,
          "containerPath": "/fldr",
          "sourceVolume": "fldr"
        }
      ],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memoryReservation": 128,
      "volumesFrom": [],
      "stopTimeout": null,
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "logConfiguration": {
        "logDriver": "awslogs",
        "awslogs-region": "eu-west-1",
        "awslogs-group": "my-cw-group"
      }
    }
  ]

尽管有awslogs-region这样的定义awslogs-group

"logConfiguration": {
            "logDriver": "awslogs",
            "awslogs-region": "eu-west-1",
            "awslogs-group": "my-cw-group"
          }

当我运行terraform apply它返回:

Error: ClientException: Log driver awslogs requires options: awslogs-region, awslogs-group

我在 StackOverflow 和 Github 都找不到相关问题。

4

1 回答 1

3
"logConfiguration": {
  "logDriver": "awslogs",
  "options": {
    "awslogs-region": "eu-west-1",
    "awslogs-group": "my-cw-group"
  }
}

这些选项需要是选项的成员,选项logConfiguration的成员,如上所示。

如果您使用 Fargate,您还需要提供awslogs-stream-prefix,如在文档中的任务定义中指定日志配置中所述。

于 2020-06-21T12:57:06.477 回答