Skip to content

[Bug]: Error deleting Vlan #902

@nebb00

Description

@nebb00

Terraform Version

v1.12.1

Equinix Provider Version

3.9.0

Effected Terraform Resources

equinix_metal_vlan
equinix_metal_port

Expected Behavior

When removing a equinix_metal_vlan together with its mapping to assigned equinix_metal_port ports.

module.metal[0].equinix_metal_vlan.vlans["2401"]: Destroying... [id=da651415-c06c-4924-843e-dae574f59f0b]
╷
│ Error: Error deleting Vlan
│ 
│ API Error HTTP 422 Cannot delete Virtual Network when port is assigned
╵

Actual Behavior

If I first remove all the port mappings, then rerun to remove the VLAN. It works without issue. Example;

# module.metal[0].equinix_metal_port.nic["sl6-tst-res-10c.tst-eu.equinixms.com.eth3"] will be updated in-place
  ~ resource "equinix_metal_port" "nic" {
        id                = "2fe46e3b-8cfd-4672-83ae-004a30473b79"
        name              = "eth3"
      ~ vlan_ids          = [
          - "da651415-c06c-4924-843e-dae574f59f0b",
            # (21 unchanged elements hidden)
        ]
        # (10 unchanged attributes hidden)
    }

Apply complete! Resources: 0 added, 17 changed, 0 destroyed.

then

  # module.metal[0].equinix_metal_vlan.vlans["2401"] will be destroyed
  # (because key ["2401"] is not in for_each map)
  - resource "equinix_metal_vlan" "vlans" {
      - description = "SL6-TST-RES-ETEP-2401" -> null
      - id          = "da651415-c06c-4924-843e-dae574f59f0b" -> null
      - metro       = "AM" -> null
      - project_id  = "196e9b5e-1265-436d-9fc5-c71e71a238b4" -> null
      - vxlan       = 2401 -> null
        # (1 unchanged attribute hidden)
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you want to perform these actions in workspace "gms-sat-tst-am6-1"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.metal[0].equinix_metal_vlan.vlans["2401"]: Destroying... [id=da651415-c06c-4924-843e-dae574f59f0b]
module.metal[0].equinix_metal_vlan.vlans["2401"]: Destruction complete after 1s

Steps to Reproduce

Try removing a VLAN and its port mappings at the same time.

Looks like its trying to destroy the VLAN first, before its removed from the port mappings

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions