-
-
Notifications
You must be signed in to change notification settings - Fork 615
Description
Description
Currently ECS Fargate does not support Restart Policy with Windows containers. (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-restart-policy.html)
When using this module, it will result in operation error ECS: UpdateService, https response error StatusCode: 400, RequestID: ea6d6b1b-472f-49a9-ae00-c3af9418b589, PlatformTaskDefinitionIncompatibilityException: One or more of the requested capabilities are not supported.
Versions
-
Module version [Required]: 6.0.5
-
Terraform version:
v1.12.1 -
Provider version(s):
- provider registry.terraform.io/hashicorp/aws v6.3.0
- provider registry.terraform.io/hashicorp/external v2.3.5
- provider registry.terraform.io/hashicorp/local v2.5.3
- provider registry.terraform.io/hashicorp/null v3.2.4
- provider registry.terraform.io/hashicorp/random v3.7.2
Reproduction Code [Required]
module "ecs-service" {
source = "terraform-aws-modules/ecs/aws//modules/service"
name = "service"
cluster_arn = module.ecs.cluster_arn
create_security_group = true
create_tasks_iam_role = true
cpu = 256
memory = 512
desired_count = 1
enable_autoscaling = true
container_definitions = {
app = {
image = "windows-container:latest"
cpu = 256
memory = 512
essential = true
readonlyRootFilesystem = false
portMappings = [{
name = "app"
protocol = "tcp"
containerPort = 80
hostPort = 80
}]
}
}
runtime_platform = {
cpu_architecture = "X86_64"
operating_system_family = "WINDOWS_SERVER_2022_CORE"
}
}
Steps to reproduce the behavior:
Standard Apply
Expected behavior
Creates service and task definition that will run a windows container on ecs fargate.
Actual behavior
Fails with
operation error ECS: UpdateService, https response error StatusCode: 400, RequestID: {UUID}, PlatformTaskDefinitionIncompatibilityException: One or more of the requested capabilities are not supported.
Additional context
I believe the solution is to replace restartPolicy
in container-definition submodule file main.tf, line 61 with:
restartPolicy = local.is_not_windows ? { for k, v in var.restartPolicy : k => v if v != null } : null
I can create Pull Request for fix.