locals {
  # Fargate compat defaults (adapter previously hardcoded these).
  requires_compatibilities = var.launch_type == "FARGATE" ? ["FARGATE"] : ["EC2"]
  network_mode             = var.launch_type == "FARGATE" ? "awsvpc" : "bridge"

  # Container definitions from image/port/env (adapter previously hardcoded this).
  container_definitions = jsonencode([{
    name      = "app"
    image     = var.image
    essential = true
    portMappings = [{
      containerPort = var.port
      hostPort      = var.port
      protocol      = "tcp"
    }]
  }])

  # Subnet list from comma-separated string.
  subnet_list = split(",", var.subnets)

  # Security groups list.
  security_groups = var.security_group != null ? [var.security_group] : []
}
