CiscoDevNet / terraform-provider-mso

Terraform Cisco MSO provider
https://registry.terraform.io/providers/CiscoDevNet/mso/latest/docs
Mozilla Public License 2.0
10 stars 32 forks source link

Bug: `mso_schema_template_anp_epg` throws error when updating resource #267

Closed edudppaz closed 5 months ago

edudppaz commented 5 months ago

Community Note

Terraform Version

1.5.6

MSO version

APIC version and APIC Platform for Site Level Resources

Affected Resource(s)

Terraform Configuration Files

Debug Output

module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["NETCENTRIC-APP-0100-EPG"]: Modifying... [id=65fc2635e93af552fe0456f5/templates/Strchd-L2-Template/anps/NETCENTRIC-APP/epgs/0100-EPG]
â•·
│ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}

Panic Output

Expected Behavior

The EPG should have been updated with a new description

Actual Behavior

Terraform errored

Steps to Reproduce

  1. Change description on the EPG
  2. terraform apply

Important Factoids

Normally, all values under the EPG resource trigger a destroy/recreate. however, with the introduction of the "description" variable, now there is a update-in-place. When trying to update the EPG (new description) terraform throws the mentioned error.

References

akinross commented 5 months ago

Hi @edudppaz,

Could you please provide your configuration and a bit more what your issue is, because the debug output message is pointing to a different resource mso_schema_template_anp_epg compared to what you have opened it for mso_schema_site_anp_epg.

edudppaz commented 5 months ago

@akinross my bad, fail copy paste. I have corrected the module name on the issue.

This is an extract of the tfplan:

2024-04-09T17:22:22.8440288Z   # module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0304-EPG"] will be updated in-place
2024-04-09T17:22:22.8441553Z   ~ resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:22:22.8442414Z       + description                = "otv-esx-vmotion"
2024-04-09T17:22:22.8443526Z         id                         = "65fc2635e93af552fe0456f5/templates/Strchd-L2-Template/anps/NETCENTRIC-APP/epgs/0304-EPG"
2024-04-09T17:22:22.8444851Z         name                       = "0304-EPG"
2024-04-09T17:22:22.8449330Z         # (13 unchanged attributes hidden)
2024-04-09T17:22:22.8449982Z     }
2024-04-09T17:22:22.8450355Z 
2024-04-09T17:22:22.8451658Z   # module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0305-EPG"] will be updated in-place
2024-04-09T17:22:22.8455401Z   ~ resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:22:22.8457831Z       + description                = "otv-monitor-db"
2024-04-09T17:22:22.8459624Z         id                         = "65fc2635e93af552fe0456f5/templates/Strchd-L2-Template/anps/NETCENTRIC-APP/epgs/0305-EPG"
2024-04-09T17:22:22.8460862Z         name                       = "0305-EPG"
2024-04-09T17:22:22.8461496Z         # (13 unchanged attributes hidden)
2024-04-09T17:22:22.8462384Z     }
2024-04-09T17:22:22.8462568Z 
2024-04-09T17:22:22.8463452Z   # module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0306-EPG"] will be updated in-place
2024-04-09T17:22:22.8464478Z   ~ resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:22:22.8465373Z       + description                = "otv-mgmt-vmware"
2024-04-09T17:22:22.8467333Z         id                         = "65fc2635e93af552fe0456f5/templates/Strchd-L2-Template/anps/NETCENTRIC-APP/epgs/0306-EPG"
2024-04-09T17:22:22.8468261Z         name                       = "0306-EPG"
2024-04-09T17:22:22.8468769Z         # (13 unchanged attributes hidden)
2024-04-09T17:22:22.8469224Z     }
2024-04-09T17:22:22.8469386Z 
2024-04-09T17:22:22.8470147Z   # module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0308-EPG"] will be updated in-place
2024-04-09T17:22:22.8471335Z   ~ resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:22:22.8472271Z       + description                = "otv-db-test"
2024-04-09T17:22:22.8473295Z         id                         = "65fc2635e93af552fe0456f5/templates/Strchd-L2-Template/anps/NETCENTRIC-APP/epgs/0308-EPG"
2024-04-09T17:22:22.8474176Z         name                       = "0308-EPG"
2024-04-09T17:22:22.8474692Z         # (13 unchanged attributes hidden)
2024-04-09T17:22:22.8475194Z     }

Result of tfapply (example, the resource might not match but is the same error for all EPGs):

2024-04-09T17:25:24.7047846Z │ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}
2024-04-09T17:25:24.7048745Z │ 
2024-04-09T17:25:24.7049710Z │   with module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0102-EPG"],
2024-04-09T17:25:24.7051114Z │   on modules/tf-aci-ndo-msite/main.tf line 269, in resource "mso_schema_template_anp_epg" "epg_anp":
2024-04-09T17:25:24.7052251Z │  269: resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:25:24.7053282Z │ 
2024-04-09T17:25:24.7053631Z ╵
2024-04-09T17:25:24.7074778Z â•·
2024-04-09T17:25:24.7079306Z │ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}
2024-04-09T17:25:24.7080225Z │ 
2024-04-09T17:25:24.7081534Z │   with module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0308-EPG"],
2024-04-09T17:25:24.7082957Z │   on modules/tf-aci-ndo-msite/main.tf line 269, in resource "mso_schema_template_anp_epg" "epg_anp":
2024-04-09T17:25:24.7084089Z │  269: resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:25:24.7084893Z │ 
2024-04-09T17:25:24.7085261Z ╵
2024-04-09T17:25:24.7126532Z â•·
2024-04-09T17:25:24.7127507Z │ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}
2024-04-09T17:25:24.7128409Z │ 
2024-04-09T17:25:24.7129324Z │   with module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0103-EPG"],
2024-04-09T17:25:24.7130735Z │   on modules/tf-aci-ndo-msite/main.tf line 269, in resource "mso_schema_template_anp_epg" "epg_anp":
2024-04-09T17:25:24.7131861Z │  269: resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:25:24.7132535Z │ 
2024-04-09T17:25:24.7132879Z ╵
2024-04-09T17:25:24.7152919Z â•·
2024-04-09T17:25:24.7153790Z │ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}
2024-04-09T17:25:24.7154658Z │ 
2024-04-09T17:25:24.7155614Z │   with module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0314-EPG"],
2024-04-09T17:25:24.7157035Z │   on modules/tf-aci-ndo-msite/main.tf line 269, in resource "mso_schema_template_anp_epg" "epg_anp":
2024-04-09T17:25:24.7158461Z │  269: resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:25:24.7159153Z │ 
2024-04-09T17:25:24.7159503Z ╵
2024-04-09T17:25:24.7177506Z â•·
2024-04-09T17:25:24.7178408Z │ Error: "Resource Not Found: Epg with name or index 65fc2635e93af552fe0456f5 not found"{}
2024-04-09T17:25:24.7179275Z │ 
2024-04-09T17:25:24.7180162Z │   with module.tf-aci-ndo-msite.mso_schema_template_anp_epg.epg_anp["SD_STD_1-NETCENTRIC-APP-0304-EPG"],
2024-04-09T17:25:24.7181567Z │   on modules/tf-aci-ndo-msite/main.tf line 269, in resource "mso_schema_template_anp_epg" "epg_anp":
2024-04-09T17:25:24.7182694Z │  269: resource "mso_schema_template_anp_epg" "epg_anp" {
2024-04-09T17:25:24.7183358Z │ 
2024-04-09T17:25:24.7183728Z ╵

Tf kode:

resource "mso_schema_template_anp_epg" "epg_anp" {
  for_each      = { for epg in local.tn_epg_flatten : epg.epg_key => epg }
  schema_id     = var.schemas[each.value.tn_name]
  template_name = "L2-Template"
  anp_name      = each.value.ap_name
  name          = each.value.epg_name
  bd_name       = each.value.epg_bd
  display_name  = each.value.epg_name
  description   = each.value.description
  depends_on = [
    mso_schema_template_anp.legacy_anp,
    mso_schema_template_bd.bd
  ]
}

Destroying the EPG and re-creating from scratch works.

akinross commented 5 months ago

Hi @edudppaz, I had a look at the resource and indeed there were a few things that were going wrong due to incorrect ID setting. Added a PR that addresses the issue, will be going through normal review process.

edudppaz commented 5 months ago

Thx for the quick response!