3

I have a json file with my AWS ECS Task definition like:

[
    {
      "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"
      }
    }
  ]

Despite define awslogs-region and awslogs-group like this:

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

When I run terraform apply it return:

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

I can't find related issues in StackOverflow, neither Github.

mrc
  • 2,845
  • 8
  • 39
  • 73
  • Your task definition and the excerpt below have conflicting values. I took those from the one above as examples when building my answer. – Alain O'Dea Jun 21 '20 at 13:03
  • @AlainO'Dea What do you mean? – mrc Jun 21 '20 at 14:15
  • 1
    You have `"awslogs-group": "my-cw-group"` in the full task definition JSON and `"awslogs-group": "pro-airflow-cloudwatch-group"` in the excerpt/snippet written below it. – Alain O'Dea Jun 21 '20 at 14:18
  • 1
    @AlainO'Dea yes, its true, a mistake when copy the code. Thx. – mrc Jun 21 '20 at 14:24
  • 1
    No worries at all! These issues are always complex and you want to be sure not to inadvertently share secrets in questions. – Alain O'Dea Jun 21 '20 at 14:40

1 Answers1

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

Those options need to be members of options which is a member of logConfiguration as shown above.

If you are using Fargate, you'll also need to provide awslogs-stream-prefix as documented in Specifying a Log Configuration in your Task Definition in the docs.

Alain O'Dea
  • 21,033
  • 1
  • 58
  • 84