Hi folks.
I’m trying to create 3 kubernetes clusters and then reference their IDs to their node-pools. The clusters are being referenced by the subnet_ids using for_each. So basically one cluster per subnet_id is being created. Next step is to create one node-pool based on the cluster_id. But the problem here is that I cannot access to the attributes of the clusters. To have a better understanding, I share the code.
K8s cluster per subnet_id:
resource "opentelekomcloud_cce_cluster_v3" "cluster_k8s" {
for_each = var.subnet_id
name = join("-", ["cluster", each.value])#"cluster-${var.subnet_id}"
cluster_type = "VirtualMachine"
flavor_id = var.flavor_id
vpc_id = var.vpc_id
subnet_id = each.value
...
...
}
Node Pool definition:
resource "opentelekomcloud_cce_node_pool_v3" "node_pool_dev" {
for_each = opentelekomcloud_cce_cluster_v3.cluster_k8s["id"]
cluster_id = each.value
name = "opentelekomcloud-cce-node-pool-test"
...
...
}
And the error I’m getting:
Error: Invalid index
│
│ on modules/cce/cce.tf line 50, in resource "opentelekomcloud_cce_node_pool_v3" "node_pool_dev":
│ 50: for_each = opentelekomcloud_cce_cluster_v3.cluster_k8s["id"]
│ ├────────────────
│ │ opentelekomcloud_cce_cluster_v3.cluster_k8s is object with 3 attributes
│
│ The given key does not identify an element in this collection value.
╵
It would be appreciated if someone can give me a clue.
Thanks