diff --git a/main.tf b/main.tf index edbf957..b9adb42 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" : ( @@ -84,11 +87,15 @@ 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" + ## This block is for if host_flavor IS set to specific pre-defined host sizes dynamic "group" { - for_each = local.host_flavor_set ? [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 { @@ -112,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 ? [] : [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 { @@ -172,6 +179,8 @@ resource "ibm_database" "enterprise_db" { timeouts { create = "120m" # Extending provisioning time to 120 minutes + update = "120m" + delete = "15m" } }