Skip to content

Commit

Permalink
fix: Remove unknown resource counts from derived inputs
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Kim <[email protected]>
  • Loading branch information
chrizkim authored and hyder committed Mar 28, 2024
1 parent df62b3d commit e2ac866
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion module-iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion module-network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
18 changes: 5 additions & 13 deletions modules/iam/tagging.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions modules/network/subnets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {})
Expand All @@ -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)
Expand Down

0 comments on commit e2ac866

Please sign in to comment.