From a742d23e8e26b85193cc614f225e59d0fe5ccf3b Mon Sep 17 00:00:00 2001 From: BJ Bloemker Date: Tue, 20 Sep 2022 13:47:09 -0500 Subject: [PATCH 1/2] Add ability to add KMS encryption to google_compute_instance_template --- modules/compute-vm/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/compute-vm/main.tf b/modules/compute-vm/main.tf index 8cbd42151c..5605312ba5 100644 --- a/modules/compute-vm/main.tf +++ b/modules/compute-vm/main.tf @@ -314,6 +314,13 @@ resource "google_compute_instance_template" "default" { } } + dynamic "disk_encryption_key" { + for_each = var.encryption != null ? [""] : [] + content { + kms_key_self_link = var.encryption.kms_key_self_link != null ? var.encryption.kms_key_self_link : null + } + } + dynamic "network_interface" { for_each = var.network_interfaces iterator = config From b6d9da9a97ab84c1cc6eeffdc40a15e1b136e4e0 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Thu, 29 Sep 2022 08:25:29 +0200 Subject: [PATCH 2/2] fix code block --- modules/compute-vm/main.tf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/compute-vm/main.tf b/modules/compute-vm/main.tf index 5605312ba5..3a5881600f 100644 --- a/modules/compute-vm/main.tf +++ b/modules/compute-vm/main.tf @@ -311,13 +311,12 @@ resource "google_compute_instance_template" "default" { config.value.source_type != "attach" ? config.value.name : null ) type = "PERSISTENT" - } - } - - dynamic "disk_encryption_key" { - for_each = var.encryption != null ? [""] : [] - content { - kms_key_self_link = var.encryption.kms_key_self_link != null ? var.encryption.kms_key_self_link : null + dynamic "disk_encryption_key" { + for_each = var.encryption != null ? [""] : [] + content { + kms_key_self_link = var.encryption.kms_key_self_link + } + } } }