From fcc2fdc9936e93c35d95fd279810787c6f6f62f8 Mon Sep 17 00:00:00 2001 From: "Thierno IB. BARRY" Date: Fri, 28 May 2021 10:35:51 +0200 Subject: [PATCH] feat: Define Root device name for Windows self-managed worker groups (#1401) NOTES: Since we now search only for Linux or Windows AMI if there is a worker groups for the corresponding plateform, we can now define different default root block device name for each plateform. Use locals `root_block_device_name` and `root_block_device_name_windows` to define your owns. --- local.tf | 21 +++++++++++---------- workers_launch_template.tf | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/local.tf b/local.tf index 11d16b7..09ff2de 100644 --- a/local.tf +++ b/local.tf @@ -78,16 +78,17 @@ locals { warm_pool = null # If this block is configured, add a Warm Pool to the specified Auto Scaling group. # Settings for launch templates - root_block_device_name = concat(data.aws_ami.eks_worker.*.root_device_name, [""])[0] # Root device name for workers. If non is provided, will assume default AMI was used. - root_kms_key_id = "" # The KMS key to use when encrypting the root storage device - launch_template_id = null # The id of the launch template used for managed node_groups - launch_template_version = "$Latest" # The latest version of the launch template to use in the autoscaling group - update_default_version = false # Update the autoscaling group launch template's default version upon each update - launch_template_placement_tenancy = "default" # The placement tenancy for instances - 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 + root_block_device_name = concat(data.aws_ami.eks_worker.*.root_device_name, [""])[0] # Root device name for Linux workers. If not provided, will assume default Linux AMI was used. + root_block_device_name_windows = concat(data.aws_ami.eks_worker_windows.*.root_device_name, [""])[0] # Root device name for Windows workers. If not provided, will assume default Windows AMI was used. + root_kms_key_id = "" # The KMS key to use when encrypting the root storage device + launch_template_id = null # The id of the launch template used for managed node_groups + launch_template_version = "$Latest" # The latest version of the launch template to use in the autoscaling group + update_default_version = false # Update the autoscaling group launch template's default version upon each update + launch_template_placement_tenancy = "default" # The placement tenancy for instances + 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 market_type = null metadata_http_endpoint = "enabled" # The state of the metadata service: enabled, disabled. metadata_http_tokens = "optional" # If session tokens are required: optional, required. diff --git a/workers_launch_template.tf b/workers_launch_template.tf index aaea961..7622565 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -438,7 +438,7 @@ resource "aws_launch_template" "workers_launch_template" { device_name = lookup( var.worker_groups_launch_template[count.index], "root_block_device_name", - local.workers_group_defaults["root_block_device_name"], + lookup(var.worker_groups_launch_template[count.index], "platform", local.workers_group_defaults["platform"]) == "windows" ? local.workers_group_defaults["root_block_device_name_windows"] : local.workers_group_defaults["root_block_device_name"], ) ebs {