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

Error: "Resource Not Found: BdDelta #252

Closed jjman4 closed 10 months ago

jjman4 commented 10 months ago

Hi All,

i've got the below error when trying to assign a L3OUT in my BD.

  │ Error: "Resource Not Found: BdDelta with name S24-10_246_194 not found in List()"{}
  │
  │   with mso_schema_site_bd_l3out.site_bd_L3out_1,
  │   on main.tf line 146, in resource "mso_schema_site_bd_l3out" "site_bd_L3out_ana":
  │  146: resource "mso_schema_site_bd_l3out" "site_bd_L3out_1" {

You can see below the sample main.tf I have (i've removed some part of the script). All the objects have been created successfully as per my check on NDO, even the BD: S24-10_246_194

provider "mso" { }

data "mso_schema" "pp01_schema" { }

data "mso_schema_template" "pp01_schema_template" { }

data "mso_schema_site" "schema_site_1" { }

data "mso_schema_site" "schema_site_2" { }

data "mso_schema_template_vrf" "vrf_main" { }

resource "mso_schema_template_bd" "bd_terraform" { name = "S24-10_246_194" display_name = "S24-10_246_194" }

resource "mso_schema_template_bd_subnet" "bd_sub_terraform" { ip = "10.246.194.0/24" }

resource "mso_schema_template_anp" "ap_terraform" { }

resource "mso_schema_template_anp_epg" "epg_terraform" { }

resource "mso_schema_site_anp_epg_domain" "site_epg_terraform_domain_ana" { }

resource "mso_schema_site_anp_epg_domain" "site_epg_terraform_domain_gal" { }

resource "mso_schema_site_bd_l3out" "site_bd_L3out_1" { schema_id = "${data.mso_schema.pp01_schema.id}" template_name = "${data.mso_schema_template.pp01_schema_template.name}" site_id = "${data.mso_schema_site.schema_site_1.site_id}" bd_name = "${mso_schema_template_bd.bd_terraform.name}" l3out_name = "MIKROTIK" }

resource "mso_schema_site_bd_l3out" "site_bd_L3out_2" { schema_id = "${data.mso_schema.pp01_schema.id}" template_name = "${data.mso_schema_template.pp01_schema_template.name}" site_id = "${data.mso_schema_site.schema_site_2.site_id}" bd_name = "${mso_schema_template_bd.bd_terraform.name}" l3out_name = "MIKROTIK" }

I do not know exactly what's wrong with my script. If you can help.

Br, J.

jjman4 commented 10 months ago

Pls down below the log i have:

2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Site Bd L3out: Beginning Creation 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Template BD: Beginning Creation 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Patch Request Container: [{"op":"add","path":"/sites/5d98502210000038006bd141-Template1/bds/S24-10_246_194/l3Outs/-","value":"MIKROTIK"}] 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begin Injection 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request after injection PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begining DO method https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [TRACE] HTTP Request Method and URL: PATCH https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Patch Request Container: [{"op":"add","path":"/templates/Template1/bds/S24-10_246_194/subnets/-","value":{"description":"TERRAFORM: Subnet used for Testing","ip":"10.246.194.0/24","noDefaultGateway":false,"querier":false,"scope":"public","shared":false}}] 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [TRACE] HTTP Request Body: {[{"op":"add","path":"/sites/5d98502210000038006bd141-Template1/bds/S24-10_246_194/l3Outs/-","value":"MIKROTIK"}]} 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begin Injection 2023-11-09T12:00:49.386+0300 [DEBUG] mso_schema_template_anp_epg.epg_terraform: applying the planned Create change 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request after injection PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Site Bd L3out: Beginning Creation 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Patch Request Container: [{"op":"add","path":"/sites/5d9850730e00003100c40416-Template1/bds/S24-10_246_194/l3Outs/-","value":"MIKROTIK"}] 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begin Injection 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request after injection PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Template Anp Epg: Beginning Creation 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Patch Request Container: [{"op":"add","path":"/templates/Template1/anps/TERRAFORM-4-TESTING/epgs/-","value":{"bdRef":{"bdName":"S24-10_246_194","schemaId":"5fbb93e4110000a013d41da8","templateName":"Template1"},"description":"","displayName":"TERRAFORM-PREPROD-APP","epgType":"application","intraEpg":"unenforced","mCastSource":false,"name":"TERRAFORM-PREPROD-APP","preferredGroup":false,"proxyArp":false,"subnets":[],"uSegEpg":false}}] 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begin Injection 2023-11-09T12:00:49.386+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP request after injection PATCH mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.556+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP Request: PATCH https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP Response: 400 400 Bad Request &{400 Bad Request 400 HTTP/1.1 1 1 map[Content-Language:[en] Content-Length:[97] Content-Type:[application/json] Date:[Thu, 09 Nov 2023 09:04:48 GMT] Server:[nginx] Strict-Transport-Security:[max-age=31536000; includeSubDomains] X-Ratelimit-Limit:[-1] X-Ratelimit-Remaining:[-1] X-Ratelimit-Reset:[1559582945]] 0xc00024bd00 97 [] false false map[] 0xc000296a00 0xc0001173f0} 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] HTTP response unique string PATCH https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false {"code":141,"message":"Resource Not Found: BdDelta with name S24-10_246_194 not found in List()"} 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Exit from do method 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [DEBUG] Begining DO method https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [TRACE] HTTP Request Method and URL: PATCH https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:49.557+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:49 [TRACE] HTTP Request Body: {[{"op":"add","path":"/templates/Template1/bds/S24-10_246_194/subnets/-","value":{"description":"TERRAFORM: Subnet used for Testing","ip":"10.246.194.0/24","noDefaultGateway":false,"querier":false,"scope":"public","shared":false}}]} 2023-11-09T12:00:49.558+0300 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot 2023-11-09T12:00:49.558+0300 [ERROR] vertex "mso_schema_site_bd_l3out.site_bd_L3out_ana" error: "Resource Not Found: BdDelta with name S24-10_246_194 not found in List()"{} 2023-11-09T12:00:50.380+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:50 [DEBUG] HTTP Request: PATCH https://xx.xx.xx.xx/mso/api/v1/schemas/5fbb93e4110000a013d41da8?validate=false 2023-11-09T12:00:50.380+0300 [DEBUG] provider.terraform-provider-mso_v0.11.1: 2023/11/09 12:00:50 [DEBUG] HTTP Response: 204 204 No Content &{204 No Content 204 HTTP/1.1 1 1 map[Cache-Control:[no-cache] Content-Language:[en] Date:[Thu, 09 Nov 2023 09:04:49 GMT] Expires:[Thu, 01 Jan 1970 00:00:01 GMT] Modified:[true] Server:[nginx] Strict-Transport-Security:[max-age=31536000; includeSubDomains] X-Frame-Options:[SAMEORIGIN] X-Ratelimit-Limit:[-1] X-Ratelimit-Remaining:[-1] X-Ratelimit-Reset:[1559582945]] {} 0 [] false false map[] 0xc000698400 0xc0001173f0}

jjman4 commented 10 months ago

And as per the terraform.tfstate entry, the BD S24-10_246_194 has been successfully created.

  "mode": "managed",

"type": "mso_schema_template_bd", "name": "bd_terraform", "provider": "provider[\"registry.terraform.io/ciscodevnet/mso\"]", "instances": [ { "schema_version": 1, "attributes": { "arp_flooding": true, "description": "", "dhcp_policies": [], "dhcp_policy": {}, "display_name": "S24-10_246_194", "id": "S24-10_246_194", "intersite_bum_traffic": true, "ipv6_unknown_multicast_flooding": "flood", "layer2_stretch": true, "layer2_unknown_unicast": "proxy", "layer3_multicast": false, "multi_destination_flooding": "flood_in_bd", "name": "S24-10_246_194", "optimize_wan_bandwidth": false, "schema_id": "5fbb93e4110000a013d41da8", "template_name": "Template1", "unicast_routing": true, "unknown_multicast_flooding": "flood", "virtual_mac_address": "", "vrf_name": "MAIN", "vrf_schema_id": "5d9861440e00003a00d02af2", "vrf_template_name": "BOTHSITES" }, "sensitive_attributes": [], "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", "dependencies": [ "data.mso_schema.base_schema", "data.mso_schema.pp01_schema", "data.mso_schema_template.base_schema_template", "data.mso_schema_template.pp01_schema_template", "data.mso_schema_template_vrf.vrf_main" ] } ] },

akinross commented 10 months ago

Hi @jjman4, what version of NDO are you using?

jjman4 commented 10 months ago

@akinross We have NDO Version: 3.7(2e)

akinross commented 10 months ago

Hi @jjman4, I see you use data-sources for the mso_schema_site. I assume these once are added to the template manually or from a different terraform config?

I think you are in a state where you have not created the site configuration for the bd, see resource mso_schema_site_bd.

Next time please format the code part as code, makes it easier to read.

jjman4 commented 10 months ago

Fantastic! It's working fine so far after adding the down below config.

Thanks a ton for this tips. I didn't even know we need to use this resource....

resource "mso_schema_site_bd" "bd_1" { schema_id = "${data.mso_schema.pp01_schema.id}" bd_name = "${mso_schema_template_bd.bd_terraform.name}" template_name = "${data.mso_schema_template.pp01_schema_template.name}" site_id = "${data.mso_schema_site.schema_site_1.site_id}" host_route = true }

resource "mso_schema_site_bd" "bd_2" { schema_id = "${data.mso_schema.pp01_schema.id}" bd_name = "${mso_schema_template_bd.bd_terraform.name}" template_name = "${data.mso_schema_template.pp01_schema_template.name}" site_id = "${data.mso_schema_site.schema_site_2.site_id}" host_route = true }

akinross commented 10 months ago

Ok will close the issue since issue resolved.