Navigating a list of object

Hello,

not sure if this has been answered before.

I have a requirement to create tag using OCI following this pattern:

namespace: Operations
tag: Environment
tag: CostCenter
namespace: departments
tag: HR
tag: IT
tag: Network

so far I have defined a variable as follows:

variable “tags” {
description = “test”
type = list(object({
tag_namespace = string
tag_namespace_description = string
tag_name = list(string)
}))
default = [
{
tag_namespace = “Operations”
tag_namespace_description = “tag to represent operations”
tag_name = [“Environment”, “CostCenter”]
},
{
tag_namespace = “departments”
tag_namespace_description = “tag to represent departments”
tag_name = [“HR”,“IT”,“Network”]
},
]
}

so far I can create the namespaces (resource “oci_identity_tag_namespace” “test_tag_namespace”).

The problem I am having is to create the tags (resource “oci_identity_tag” “test_tag”) for each namespace, basically, iterate the structure so I call resource “oci_identity_tag” “test_tag” for each tag of each namespace.

any help will be appreciated.

Versions:
Terraform v0.12.7

  • provider.oci v3.33.0
  • provider.template v2.1.0