diff --git a/module-iam.tf b/module-iam.tf index 3cf61c96..7b20c0de 100644 --- a/module-iam.tf +++ b/module-iam.tf @@ -2,7 +2,7 @@ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl data "oci_identity_availability_domains" "all" { - compartment_id = local.compartment_id + compartment_id = local.tenancy_id != "unknown" ? local.tenancy_id : local.compartment_id } locals { diff --git a/module-network.tf b/module-network.tf index b70c9dbf..5543057a 100644 --- a/module-network.tf +++ b/module-network.tf @@ -2,7 +2,7 @@ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl data "oci_core_vcn" "oke" { - count = coalesce(var.vcn_id, "none") != "none" ? 1 : 0 + count = var.create_vcn ? 0 : 1 vcn_id = coalesce(var.vcn_id, "none") } diff --git a/modules/iam/tagging.tf b/modules/iam/tagging.tf index 972bd433..adfd04e4 100644 --- a/modules/iam/tagging.tf +++ b/modules/iam/tagging.tf @@ -13,13 +13,6 @@ data "oci_identity_tag_namespaces" "oke" { state = "ACTIVE" // TODO Support reactivation of retired namespace w/ update } -data "oci_identity_tags" "oke" { - count = var.create_iam_resources && local.tag_namespace_id_found != null ? 1 : 0 - provider = oci.home - tag_namespace_id = local.tag_namespace_id_found - state = "ACTIVE" // TODO Support reactivation of retired tag w/ update -} - locals { # Filtered value from data source (only 1 by name, or null) # Identified tag namespace ID when not created and used @@ -31,7 +24,6 @@ locals { var.create_iam_resources, var.create_iam_tag_namespace, local.tag_namespace_id_found == null, - one(data.oci_identity_tags.oke[*].tags) == null, ]) # Map of standard tags & descriptions to be created if enabled @@ -64,17 +56,17 @@ resource "oci_identity_tag_namespace" "oke" { description = "Tag namespace for OKE resources" name = var.tag_namespace # defined_tags = local.defined_tags - freeform_tags = local.freeform_tags + freeform_tags = local.freeform_tags lifecycle { ignore_changes = [defined_tags, freeform_tags] } } resource "oci_identity_tag" "oke" { - provider = oci.home - for_each = local.create_iam_tag_namespace ? local.tags : {} #{ for k, v in oci_identity_tag_namespace.oke : k => local.tags } # local.create_iam_tag_namespace ? local.tags : {} - description = each.value - name = each.key + provider = oci.home + for_each = local.create_iam_tag_namespace ? local.tags : {} #{ for k, v in oci_identity_tag_namespace.oke : k => local.tags } # local.create_iam_tag_namespace ? local.tags : {} + description = each.value + name = each.key # defined_tags = local.defined_tags freeform_tags = local.freeform_tags tag_namespace_id = one(oci_identity_tag_namespace.oke[*].id) diff --git a/modules/network/subnets.tf b/modules/network/subnets.tf index 46997bfb..a63780df 100644 --- a/modules/network/subnets.tf +++ b/modules/network/subnets.tf @@ -79,7 +79,7 @@ locals { # - Subnet is configured with newbits and/or netnum/cidr # - Not configured with create == 'never' # - Not configured with an existing 'id' - subnets_to_create = length(var.vcn_cidrs) > 0 ? merge( + subnets_to_create = merge( { for k, v in local.subnet_info : k => # Override `create = true` if configured with "always" merge(v, lookup(try(lookup(var.subnets, k), { create = "never" }), "create", "auto") == "always" ? { "create" = true } : {}) @@ -92,7 +92,7 @@ locals { ]), ]) } - ) : {} + ) subnet_output = { for k, v in var.subnets : k => lookup(v, "id", null) != null ? v.id : lookup(lookup(oci_core_subnet.oke, k, {}), "id", null)