Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: can't create a device with metro = any #624

Open
ctreatma opened this issue Mar 14, 2024 · 2 comments
Open

[Bug]: can't create a device with metro = any #624

ctreatma opened this issue Mar 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ctreatma
Copy link
Contributor

ctreatma commented Mar 14, 2024

Terraform Version

Terraform v1.5.7 on darwin_arm64

Equinix Provider Version

version = "1.32.0"

Affected Terraform Resources

equinix_metal_device

Terraform Config Files

resource "equinix_metal_device" "test" {
  # ... other device settings
  metro = "any"
}

Debug Output

No response

Panic Output

No response

Expected Behavior

The device should be created successfully, and a subsequent terraform plan should not show any changes

Actual Behavior

The device is created successfully, but terraform plan always wants to delete and recreate the device because the config value any does not match the actual metro in which the device was deployed (e.g., sv)

Steps to Reproduce

  1. Configure an equinix_metal_device resource with metro = "any"
  2. Run terraform plan
  3. Run terraform apply
  4. Run terraform plan again and see that the device will be recreated
@ctreatma ctreatma added the bug Something isn't working label Mar 14, 2024
@ctreatma
Copy link
Contributor Author

Workarounds for using metro = "any":

To avoid deleting and recreating a device created with metro = "any", you can tell terraform to ignore changes to the metro attribute:

resource "equinix_metal_device" "test" {
  # ... other device settings
  metro = "any"

  lifecycle {
    ignore_changes = ["metro"]
  }
}

If you need to reference the actual metro in which the device was created (for example, you want to create the device in any metro and then create a VLAN in the same metro), you can use an equinix_metal_device datasource to determine the deployed metro:

resource "equinix_metal_device" "test" {
  # ... other device settings
  metro = "any"

  lifecycle {
    ignore_changes = ["metro"]
  }
}

data "equinix_metal_device" "test" {
  id = equinix_metal_device.test.id
}

resource "equinix_metal_vlan" "test" {
  metro = data.equinix_metal_device.test.metro
}

@displague
Copy link
Member

With this, the documentation should be updated to report the behavior change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants