As part of my terraform use case - large numbers of objects are crated for ACI - the details of which would look like an enlarged version of the csv below:
UID,tn_id,AP
1,TNT_1AP_1
2,TNT_1,AP_2
3,TNT_2,AP_1
4,TNT_2,AP_2
Using the following code:
" Import and decode csv data
locals {
csv_data = file("./variables3.csv")
instances = csvdecode(local.csv_data)
}
Create tenants for values under the tn_id column
resource “aci_tenant” “example” {
#for_each = { for inst in local.instances : inst.tn_id => inst }
for_each = { for inst in local.instances : inst.UID => inst }
name = each.value.tn_id
}
Terraform will then plan and create the tenant twice.
Terraform will perform the following actions:
aci_tenant.example[“1”] will be created
- resource “aci_tenant” “example” {
+ annotation = “orchestrator:terraform”
+ description = (known after apply)
+ id = (known after apply)
+ name = “TNT_1”
+ name_alias = (known after apply)
}
aci_tenant.example[“2”] will be created- resource “aci_tenant” “example” {
+ annotation = “orchestrator:terraform”
+ description = (known after apply)
+ id = (known after apply)
+ name = “TNT_1”
+ name_alias = (known after apply)
}
The tenant must be specified within the csv due to the hierarchical structure within ACI. And with larger deployments this will cause significant unnecessary load for the ACI controllers. Is there a way to somehow filter this so that it does not attempt to create duplicate tenants multiple times?