diff --git a/local.tf b/local.tf index e268a38f33..c72af075f6 100644 --- a/local.tf +++ b/local.tf @@ -68,7 +68,7 @@ locals { suspended_processes = ["AZRebalance"] # A list of processes to suspend. i.e. ["AZRebalance", "HealthCheck", "ReplaceUnhealthy"] target_group_arns = null # A list of Application LoadBalancer (ALB) target group ARNs to be associated to the autoscaling group enabled_metrics = [] # A list of metrics to be collected i.e. ["GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity"] - placement_group = "" # The name of the placement group into which to launch the instances, if any. + placement_group = null # The name of the placement group into which to launch the instances, if any. service_linked_role_arn = "" # Arn of custom service linked role that Auto Scaling group will use. Useful when you have encrypted EBS termination_policies = [] # A list of policies to decide how the instances in the auto scale group should be terminated. platform = "linux" # Platform of workers. either "linux" or "windows" @@ -78,7 +78,7 @@ locals { root_kms_key_id = "" # The KMS key to use when encrypting the root storage device launch_template_version = "$Latest" # The lastest version of the launch template to use in the autoscaling group launch_template_placement_tenancy = "default" # The placement tenancy for instances - launch_template_placement_group = "" # The name of the placement group into which to launch the instances, if any. + launch_template_placement_group = null # The name of the placement group into which to launch the instances, if any. root_encrypted = false # Whether the volume should be encrypted or not eni_delete = true # Delete the Elastic Network Interface (ENI) on termination (if set to false you will have to manually delete before destroying) cpu_credits = "standard" # T2/T3 unlimited mode, can be 'standard' or 'unlimited'. Used 'standard' mode as default to avoid paying higher costs diff --git a/workers_launch_template.tf b/workers_launch_template.tf index ebc997e9da..bdf1efdfb0 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -294,17 +294,17 @@ resource "aws_launch_template" "workers_launch_template" { ) } - placement { - tenancy = lookup( - var.worker_groups_launch_template[count.index], - "launch_template_placement_tenancy", - local.workers_group_defaults["launch_template_placement_tenancy"], - ) - group_name = lookup( - var.worker_groups_launch_template[count.index], - "launch_template_placement_group", - local.workers_group_defaults["launch_template_placement_group"], - ) + dynamic placement { + for_each = lookup(var.worker_groups_launch_template[count.index], "launch_template_placement_group", local.workers_group_defaults["launch_template_placement_group"]) != null ? [lookup(var.worker_groups_launch_template[count.index], "launch_template_placement_group", local.workers_group_defaults["launch_template_placement_group"])] : [] + + content { + tenancy = lookup( + var.worker_groups_launch_template[count.index], + "launch_template_placement_tenancy", + local.workers_group_defaults["launch_template_placement_tenancy"], + ) + group_name = placement.value + } } dynamic instance_market_options {