How to specify an operating System Family for Fargate task definition?

Viewed 730

I am using terraform to create a Fargate task definition but I am having some difficulty specifying the Runtime platform version. According to AWS's docs the task definition operatingSystemFamily property does exist. Its default value is LINUX. I would like to change that to Windows Server 2019 Core as I would like to use Windows containers on Fargate.

Having said that, I am unable to find it on the Terraform's aws_ecs_task_definition resource documentation.

This is my task definition:

resource "aws_ecs_task_definition" "transform_service" {
  family                   = "${var.app_name}-transform-service-task"
  network_mode             = "awsvpc"
  requires_compatibilities = ["FARGATE"]
  cpu                = 2 * 1024  #2 vCPU
  memory             = 16 * 1024 # 16GB
  execution_role_arn = aws_iam_role.transform_service_task_execution_role.arn
  
  container_definitions = jsonencode([{
    name      = "transform-service-container-${var.environment}"
    image     = "${var.transform_service_repository_url}:latest"
    essential = true
    environment = [{
      "name" : "DOTNET_ENVIRONMENT", "value" : "Development"
    }]
    },

  ])
}
2 Answers
resource "aws_ecs_task_definition" "test" {
  family                   = "test"
  requires_compatibilities = ["FARGATE"]
  network_mode             = "awsvpc"
  cpu                      = 1024
  memory                   = 2048
  container_definitions    = <<TASK_DEFINITION
[
  {
    "name": "iis",
    "image": "mcr.microsoft.com/windows/servercore/iis",
    "cpu": 1024,
    "memory": 2048,
    "essential": true
  }
]
TASK_DEFINITION

  runtime_platform {
    operating_system_family = "WINDOWS_SERVER_2019_CORE"
    cpu_architecture        = "X86_64"
  }
}

Release notes here: https://github.com/hashicorp/terraform-provider-aws/pull/22016

Adds platform runtime properties and validation based on https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html runtime_platform { operating_system_family = "WINDOWS_SERVER_2019_CORE" cpu_architecture = "X86_64" }

Related