I’m very new to Terraform so this may be trivial. Is it possible to reference another resource by using data from a CSV file?
#CSV FILE CONTENTS
IPG-NAME,LL-POL,CDP-POL
TEST01-APG,default,cdp_enable
TEST02-APG,default,cdp_disable
TEST03-APG,default,cdp_enable
TEST04-APG,default,cdp_disable
# CDP RESOURCES
resource "aci_cdp_interface_policy" "cdp_enable" {
name = "CDP_Enabled"
admin_st = "enabled"
annotation = "none"
}
resource "aci_cdp_interface_policy" "cdp_disable" {
name = "CDP_Disabled"
admin_st = "disabled"
annotation = "none"
}
# Access Port Policy Group Resources
resource "aci_leaf_access_port_policy_group" "ap_pg_prod"{
for_each = { for pg in local.acc_int_pg : pg.IPG-NAME => pg }
name = each.value.IPG-NAME
relation_infra_rs_cdp_if_pol = "aci_cdp_interface_policy.${each.value.CDP-POL}".id #LINE 197
}
I’m getting the following after terraform plan is run:
Error: Unsupported attribute
│
│ on access_policies_1.tf line 197, in resource “aci_leaf_access_port_policy_group” “ap_pg_prod”:
│ 197: relation_infra_rs_cdp_if_pol = “aci_cdp_interface_policy.${each.value.CDP-POL}”.id
│
│ Can’t access attributes on a primitive-typed value (string).