From 3c0ffcff22365f6f644373e59e34b649f566c153 Mon Sep 17 00:00:00 2001 From: omjadas Date: Thu, 7 Oct 2021 23:26:53 +1100 Subject: [PATCH] feat: Allow snapshot_id to be specified for additional_ebs_volumes (#1431) --- locals.tf | 3 ++- workers.tf | 5 +++++ workers_launch_template.tf | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/locals.tf b/locals.tf index 9835831912..af8c2deff4 100644 --- a/locals.tf +++ b/locals.tf @@ -78,10 +78,11 @@ locals { 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 = var.default_platform # Platform of workers. Either "linux" or "windows". - additional_ebs_volumes = [] # A list of additional volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), volume_size, volume_type, iops, throughput, encrypted, kms_key_id (only on launch-template), delete_on_termination. Optional values are grabbed from root volume or from defaults + additional_ebs_volumes = [] # A list of additional volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), volume_size, volume_type, iops, throughput, encrypted, kms_key_id (only on launch-template), delete_on_termination, snapshot_id. Optional values are grabbed from root volume or from defaults additional_instance_store_volumes = [] # A list of additional instance store (local disk) volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), virtual_name. warm_pool = null # If this block is configured, add a Warm Pool to the specified Auto Scaling group. timeouts = {} # A map of timeouts for create/update/delete operations + snapshot_id = null # A custom snapshot ID. # Settings for launch templates 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. diff --git a/workers.tf b/workers.tf index f2cd7cbf1b..8dc2754e56 100644 --- a/workers.tf +++ b/workers.tf @@ -344,6 +344,11 @@ resource "aws_launch_configuration" "workers" { "encrypted", local.workers_group_defaults["root_encrypted"], ) + snapshot_id = lookup( + block_device_mappings.value, + "snapshot_id", + local.workers_group_defaults["snapshot_id"], + ) delete_on_termination = lookup(ebs_block_device.value, "delete_on_termination", true) } } diff --git a/workers_launch_template.tf b/workers_launch_template.tf index d713cf412d..df2928dc5d 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -524,6 +524,11 @@ resource "aws_launch_template" "workers_launch_template" { "kms_key_id", local.workers_group_defaults["root_kms_key_id"], ) + snapshot_id = lookup( + block_device_mappings.value, + "snapshot_id", + local.workers_group_defaults["snapshot_id"], + ) delete_on_termination = lookup(block_device_mappings.value, "delete_on_termination", true) } }