Skip to content

iosxe_interface_switchport Import Skips VLANs Under add-vlans.add[].vlans #377

@ckone987

Description

@ckone987

When importing an IOS-XE trunk interface using iosxe_interface_switchport, the provider only imports VLANs from allowed.vlan-v2.vlan-choices.vlans and ignores all VLANs defined under allowed.vlan-v2.add-vlans.add[].vlans. As a result, trunk_allowed_vlans in the Terraform state is incomplete and does not reflect the full list configured on the device.

Here is an extract of the Terraform state

{
  "mode": "managed",
  "type": "iosxe_interface_switchport",
  "name": "GigabitEthernet1-0-21",
  "provider": "provider[\"registry.terraform.io/ciscodevnet/iosxe\"]",
  "instances": [
    {
      "schema_version": 0,
      "attributes": {
        "access_vlan": null,
        "delete_mode": null,
        "device": null,
        "host": false,
        "id": "Cisco-IOS-XE-native:native/interface/GigabitEthernet=1%2F0%2F21/switchport-config/switchport",
        "mode_access": false,
        "mode_dot1q_tunnel": false,
        "mode_private_vlan_host": false,
        "mode_private_vlan_promiscuous": false,
        "mode_private_vlan_trunk": false,
        "mode_trunk": true,
        "name": "1/0/21",
        "nonegotiate": true,
        "trunk_allowed_vlans": "10,20,30,40,50,60,70,74,81,90-93,299",
        "trunk_allowed_vlans_none": false,
        "trunk_native_vlan": null,
        "trunk_native_vlan_tag": null,
        "type": "GigabitEthernet"
      },
      "sensitive_attributes": [],
      "identity_schema_version": 0,
    }
  ]
}

Here is the response from the device

2025-11-20T11:12:36.661-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2: 2025/11/20 11:12:36 [DEBUG] HTTP Request: GET, https://10.10.10.10/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1%2F0%2F21/switchport-config/switchport, {}
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2: 2025/11/20 11:12:36 [DEBUG] HTTP Response: {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:   "Cisco-IOS-XE-native:switchport": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:     "Cisco-IOS-XE-switch:mode": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:       "trunk": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:       }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:     },
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:     "Cisco-IOS-XE-switch:nonegotiate": [null],
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:     "Cisco-IOS-XE-switch:trunk": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:       "allowed": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:         "vlan-v2": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:           "vlan-choices": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:             "vlans": "10,20,30,40,50,60,70,74,81,90-93,299"
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:           },
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:           "add-vlans": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:             "add": [
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:               {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:                 "vlans": "331-337,348,350-352,602,700,750,802,902,942"
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:               }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:             ]
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:           }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:         },
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:         "vlan": {
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:           "vlans": "10,20,30,40,50,60,70,74,81,90-93,299"
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:         }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:       }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:     }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2:   }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2: }
2025-11-20T11:12:36.864-1000 [DEBUG] provider.terraform-provider-iosxe_v0.10.2: 2025/11/20 11:12:36 [DEBUG] Exit from Do method

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions