From edbf3f0afc4084918bbc569dc2621822f41cb7fe Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Thu, 21 Nov 2024 11:31:20 +0000 Subject: [PATCH 1/4] feat: add workaround for groups --- main.tf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 59d7d19..b4d589f 100644 --- a/main.tf +++ b/main.tf @@ -84,11 +84,14 @@ resource "ibm_database" "enterprise_db" { } } + # Workaround for https://github.ibm.com/GoldenEye/issues/issues/11359 + # means that no `group` block is added when restoring from backup + ## This for_each block is NOT a loop to attach to multiple group blocks. ## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set ## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant" dynamic "group" { - for_each = local.host_flavor_set ? [1] : [] + for_each = local.host_flavor_set && var.backup_crn == null ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases host_flavor { @@ -112,7 +115,7 @@ resource "ibm_database" "enterprise_db" { ## This block is for if host_flavor IS NOT set dynamic "group" { - for_each = local.host_flavor_set ? [] : [1] + for_each = local.host_flavor_set && var.backup_crn == null ? [] : [1] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases memory { @@ -172,6 +175,8 @@ resource "ibm_database" "enterprise_db" { timeouts { create = "120m" # Extending provisioning time to 120 minutes + update = "120m" + delete = "15m" } } From cc4412c2462ede5705b87fcb0eb21e1fe927f9ed Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Thu, 21 Nov 2024 11:38:32 +0000 Subject: [PATCH 2/4] feat: add workaround for groups --- main.tf | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index b4d589f..1ab6306 100644 --- a/main.tf +++ b/main.tf @@ -27,6 +27,9 @@ locals { # Determine if host_flavor is used host_flavor_set = var.member_host_flavor != null ? true : false + # Determine if restore, from backup or point in time recovery + recovery_mode = var.backup_crn != null || var.pitr_id != null + # Determine what KMS service is being used for database encryption kms_service = var.kms_key_crn != null ? ( can(regex(".*kms.*", var.kms_key_crn)) ? "kms" : ( @@ -86,12 +89,13 @@ resource "ibm_database" "enterprise_db" { # Workaround for https://github.ibm.com/GoldenEye/issues/issues/11359 # means that no `group` block is added when restoring from backup + # or point in time recovery ## This for_each block is NOT a loop to attach to multiple group blocks. ## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set ## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant" dynamic "group" { - for_each = local.host_flavor_set && var.backup_crn == null ? [1] : [] + for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" && !local.recovery_mode ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases host_flavor { @@ -115,15 +119,18 @@ resource "ibm_database" "enterprise_db" { ## This block is for if host_flavor IS NOT set dynamic "group" { - for_each = local.host_flavor_set && var.backup_crn == null ? [] : [1] + for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" && !local.recovery_mode ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases - memory { - allocation_mb = var.member_memory_mb + host_flavor { + id = var.member_host_flavor } disk { allocation_mb = var.member_disk_mb } + memory { + allocation_mb = var.member_memory_mb + } cpu { allocation_count = var.member_cpu_count } From 1e2ee3533b0f60e1832b76cfe40a0c772a0ff8f4 Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Mon, 25 Nov 2024 13:27:41 +0000 Subject: [PATCH 3/4] fix: if condition --- main.tf | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/main.tf b/main.tf index 66020b2..095148e 100644 --- a/main.tf +++ b/main.tf @@ -93,9 +93,9 @@ resource "ibm_database" "enterprise_db" { ## This for_each block is NOT a loop to attach to multiple group blocks. ## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set - ## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant" + ## This block is for if host_flavor IS set to specific pre-defined host sizes dynamic "group" { - for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" && !local.recovery_mode ? [1] : [] + for_each = local.host_flavor_set && !local.recovery_mode ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases host_flavor { @@ -119,18 +119,15 @@ resource "ibm_database" "enterprise_db" { ## This block is for if host_flavor IS NOT set dynamic "group" { - for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" && !local.recovery_mode ? [1] : [] + for_each = local.host_flavor_set && !local.recovery_mode ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases - host_flavor { - id = var.member_host_flavor + memory { + allocation_mb = var.member_memory_mb } disk { allocation_mb = var.member_disk_mb } - memory { - allocation_mb = var.member_memory_mb - } cpu { allocation_count = var.member_cpu_count } From 8236aa186f4b4f4f1054dc25cdd62681c87f5f1f Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 25 Nov 2024 13:31:07 +0000 Subject: [PATCH 4/4] Update main.tf --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 095148e..b9adb42 100644 --- a/main.tf +++ b/main.tf @@ -119,7 +119,7 @@ resource "ibm_database" "enterprise_db" { ## This block is for if host_flavor IS NOT set dynamic "group" { - for_each = local.host_flavor_set && !local.recovery_mode ? [1] : [] + for_each = !local.host_flavor_set && !local.recovery_mode ? [1] : [] content { group_id = "member" # Only member type is allowed for IBM Cloud Databases memory {