General discussion

  • Creator
    Topic
  • #4023816

    Terraform with Cisco ACI – Associate Contract to EPG – Invalid Index

    Locked

    by ammusk354 ·

    Tags: 

    0

    Still fairly new with programming, and diving into the deep end of terraform. I am working through learning ACI with Terraform and getting a error. I think i am just declaring my objects wrong, but can’t figure it out. i have tried to leave out a lot of redundant config and errors for brevity.

    │ Error: Invalid index

    │ on ../modules/tenant/contracts.tf line 38, in resource “aci_epg_to_contract” “terraform_epgweb_contract”:
    │ 38: application_epg_dn = aci_application_epg.epga[each.key].id
    │ ├────────────────
    │ │ aci_application_epg.epga is object with 2 attributes
    │ │ each.key is “terraform_three”

    │ The given key does not identify an element in this collection value.
    Problem: Assign 3 contracts, to each EPG (2 epgs in each App profile).

    For App A that I created, I have epga which consists of a Web_EPG and DB EPG. For App B that I created, I have epgb which consists of a Web_EPG and DB EPG.

    module “my_tenant” {
    source = “../modules/tenant”
    epga = {
    web_epg = {
    name = “web_epg”
    application_profile = “app_a_ap”
    bridge_domain = “app_a_bd”
    },
    db_epg = {
    name = “db_epg”
    application_profile = “app_a_ap”
    bridge_domain = “app_a_bd”
    }
    }
    For the contracts I am using two different epg contracts – epga_contracts and epgb_contracts.

    epga_contracts = {
    terraform_one = {
    epg = “web_epg”,
    contract = “contract_sql”,
    contract_type = “consumer”
    },
    terraform_two = {
    epg = “db_epg”,
    contract = “contract_sql”,
    contract_type = “provider”
    },
    terraform_three = {
    epg = “web_epg”,
    contract = “contract_web”,
    contract_type = “provider”
    }
    }

    to assign them i am trying to loop through both of the web contracts and both of the db contracts that are already created to assign them to the EPG’s

    resource “aci_epg_to_contract” “terraform_epgweb_contract” {
    for_each = var.epga_contracts
    application_epg_dn = aci_application_epg.epga[each.key].id
    contract_dn = aci_contract.terraform_contract[each.value.contract].id
    contract_type = each.value.contract_type
    }

    resource “aci_epg_to_contra

All Comments

Viewing 0 reply threads