Skip to content

Tags on ECS tasks are not being propagated from the ECS task definition tags #19422

Description

@mimozell

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.14.5
Provider version: 3.36.0 and 3.40.0

Affected Resource(s)

  • aws_ecs_task_definition

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource aws_ecs_task_definition service {
  container_definitions = <<-JSON
    [
      {
        "name": "${var.service-name}",
        "image": "${var.image}",
        "essential": true,
        "portMappings": [
          {
            "containerPort": ${var.container_port},
            "hostPort": ${var.container_port}
          }
        ],
        "environment" : ${jsonencode(local.env_vars)},
        "secrets" : ${jsonencode(var.secrets)},
        "logConfiguration": {
          "logDriver": "awslogs",
          "options": {
            "awslogs-group": "${var.awslogs-group}",
            "awslogs-region": "${var.awslogs-region}",
            "awslogs-stream-prefix": "web"
          }
        }
        %{if var.ulimit != null} ,
        "Ulimits": ${jsonencode(var.ulimit)}
        %{endif}
      }
    ]
  JSON

  family = "${var.service-name}-${var.environment}"
  task_role_arn = var.task_role_arn
  execution_role_arn = var.task_role_arn
  requires_compatibilities = ["FARGATE"]
  network_mode = "awsvpc"
  cpu = var.container_cpu
  memory = var.container_memory

  tags = {
    Environment = var.environment
    AppName = var.service-name
  }
}

Debug Output

Panic Output

Expected Behavior

When adding tags to an AWS Task Definition resource, I expect the tags to be added to the task created based on that task definition as described here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html#tag-resources. That means that the task definition tags should be propagated to the task that is based on it.

Actual Behavior

Tags are not being propagated as expected.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000

Metadata

Metadata

Assignees

No one assigned

    Labels

    service/ecsIssues and PRs that pertain to the ecs service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions