Skip to content

Commit

Permalink
- fix for_each with list
Browse files Browse the repository at this point in the history
- add platform_version condition
  • Loading branch information
qemanuel committed Nov 27, 2023
1 parent a07d90c commit 5113e33
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ resource "aws_ecs_task_definition" "main" {
dynamic "volume" {
for_each = var.host_volumes
content {
name = each.value.name
host_path = lookup(each.value, "host_path", null)
name = volume.value.name
host_path = lookup(volume.value, "host_path", null)
}
}

dynamic "volume" {
for_each = var.docker_volumes
content {
name = each.key
host_path = lookup(each.value, "host_path", null)
name = volume.value.name
host_path = lookup(volume.value, "host_path", null)
docker_volume_configuration {
autoprovision = lookup(each.value, "autoprovision", true)
driver_opts = lookup(each.value, "driver_opts", null)
driver = lookup(each.value, "driver", null)
scope = lookup(each.value, "scope", "shared")
autoprovision = lookup(volume.value, "autoprovision", true)
driver_opts = lookup(volume.value, "driver_opts", null)
driver = lookup(volume.value, "driver", null)
scope = lookup(volume.value, "scope", "shared")
}
}
}

dynamic "volume" {
for_each = var.efs_volumes
content {
name = each.key
host_path = lookup(each.value, "host_path", null)
name = volume.value.name
host_path = lookup(volume.value, "host_path", null)
efs_volume_configuration {
file_system_id = each.value.file_system_id
root_directory = lookup(each.value, "root_directory", null)
transit_encryption = lookup(each.value, "transit_encryption", "DISABLED")
transit_encryption_port = lookup(each.value, "transit_encryption_port", null)
file_system_id = volume.value.file_system_id
root_directory = lookup(volume.value, "root_directory", null)
transit_encryption = lookup(volume.value, "transit_encryption", "DISABLED")
transit_encryption_port = lookup(volume.value, "transit_encryption_port", null)
authorization_config {
access_point_id = lookup(each.value.authorization_config, "access_point_id", null)
iam = lookup(each.value.authorization_config, "iam", "DISABLED")
access_point_id = lookup(volume.value.authorization_config, "access_point_id", null)
iam = lookup(volume.value.authorization_config, "iam", "DISABLED")
}
}
}
Expand All @@ -66,7 +66,7 @@ resource "aws_ecs_task_definition" "main" {
resource "aws_ecs_service" "main" {
name = var.release_name
cluster = data.aws_ecs_cluster.main.arn
platform_version = "LATEST"
platform_version = var.launch_type == "FARGATE" || var.capacity_provider == "FARGATE" ? "LATEST" : null
propagate_tags = "TASK_DEFINITION"
scheduling_strategy = var.scheduling_strategy
desired_count = var.replica_count
Expand Down Expand Up @@ -94,8 +94,8 @@ resource "aws_ecs_service" "main" {
dynamic "placement_constraints" {
for_each = var.placement_constraints
content {
type = each.type
expression = each.expression
type = placement_constraints.value.type
expression = placement_constraints.value.expression
}
}

Expand Down

0 comments on commit 5113e33

Please sign in to comment.