equinix / terraform-provider-equinix

Terraform Equinix provider
https://deploy.equinix.com/labs/terraform-provider-equinix/
MIT License
47 stars 45 forks source link

"Error: Provider produced inconsistent final plan" for .seller_region #343

Open nickzxcv opened 1 year ago

nickzxcv commented 1 year ago

Community Note

Terraform Version

Terraform v1.5.0 on linux_amd64

Affected Resource(s)

equinix_ecx_l2_connection

Terraform Configuration Files

main.tf:

terraform {
  required_providers {
    equinix = {
      source = "equinix/equinix"
    }
  }
}

data "external" "get_bearer_token" {
  program = ["../equinix-production-access-token.bash"]
}

provider "equinix" {
  token = data.external.get_bearer_token.result.access_token
}

data "equinix_ecx_port" "dot1q-primary" {
  name = var.equinix_primary_port_name
}

data "equinix_ecx_port" "dot1q-secondary" {
  name = var.equinix_secondary_port_name
}

data "equinix_ecx_l2_sellerprofile" "gcpi-1" {
  name                     = "Google Cloud Partner Interconnect Zone 1"
  organization_global_name = "GOOGLE"
}

data "equinix_ecx_l2_sellerprofile" "gcpi-2" {
  name                     = "Google Cloud Partner Interconnect Zone 2"
  organization_global_name = "GOOGLE"
}

resource "google_compute_interconnect_attachment" "asdf" {
  name                     = var.name
  project                  = var.project_id
  region                   = var.region
  edge_availability_domain = var.availability_domain_1
  type                     = var.type
  router                   = google_compute_router.asdf.id
  mtu                      = var.mtu
}

resource "google_compute_router" "asdf" {
  name    = "${var.name}-router-1"
  project = var.project_id
  region  = var.region
  network = google_compute_network.asdf.name
  bgp {
    asn = 16550
  }
}

resource "google_compute_network" "asdf" {
  name                    = "${var.name}-network-1"
  project                 = var.project_id
  auto_create_subnetworks = false
}

resource "equinix_ecx_l2_connection" "gcpi-dot1q" {
  name              = "tf-gcpi-dot1q"
  profile_uuid      = data.equinix_ecx_l2_sellerprofile.gcpi-1.uuid
  speed             = 50
  speed_unit        = "MB"
  notifications     = ["nicks@example.com"]
  port_uuid         = data.equinix_ecx_port.dot1q-primary.uuid
  vlan_stag         = 1600
  seller_region     = google_compute_interconnect_attachment.asdf.region
  seller_metro_code = var.equinix_metro_code
  authorization_key = google_compute_interconnect_attachment.asdf.pairing_key
}

Debug Output

https://gist.github.com/nickzxcv/2e1678a6b575729efe59e2fa469b29b1

Expected Behavior

Create the equinix_ecx_l2_connection

Actual Behavior

Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.

Enter a value: yes

google_compute_network.asdf: Creating... google_compute_network.asdf: Still creating... [10s elapsed] google_compute_network.asdf: Still creating... [20s elapsed] google_compute_network.asdf: Creation complete after 22s [id=projects/infra-258014/global/networks/asdf-network-1] google_compute_router.asdf: Creating... google_compute_router.asdf: Still creating... [10s elapsed] google_compute_router.asdf: Still creating... [20s elapsed] google_compute_router.asdf: Creation complete after 21s [id=projects/infra-258014/regions/us-east4/routers/asdf-router-1] google_compute_interconnect_attachment.asdf: Creating... google_compute_interconnect_attachment.asdf: Still creating... [10s elapsed] google_compute_interconnect_attachment.asdf: Creation complete after 12s [id=projects/infra-258014/regions/us-east4/interconnectAttachments/asdf] ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for equinix_ecx_l2_connection.gcpi-dot1q to include new values learned so far during apply, provider "registry.terraform.io/equinix/equinix" produced an invalid new value for │ .seller_region: was cty.StringVal("us-east4"), but now cty.StringVal("https://www.googleapis.com/compute/v1/projects/infra-258014/regions/us-east4"). │ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵

Steps to Reproduce

  1. terraform apply
nickzxcv commented 1 year ago

I also tried setting seller_region = var.region instead of getting the region name from the interconnect, and this came up with a different error:

equinix_ecx_l2_connection.gcpi-dot1q: Creating...
╷
│ Error: Equinix REST API error: Message: "Bad Request", HTTPCode: 400, ApplicationErrors: [Code: "IC-LAYER2-AUTH-004", Property: "authorizationKey", Message: "Authentication key pattern did not match regex specification", AdditionalInfo: "Pairing key must end with /1"]
│
│   with equinix_ecx_l2_connection.gcpi-dot1q,
│   on main.tf line 62, in resource "equinix_ecx_l2_connection" "gcpi-dot1q":
│   62: resource "equinix_ecx_l2_connection" "gcpi-dot1q" {
│
╵
nickzxcv commented 1 year ago

The "Pairing key must end with /1" problem was the same as https://github.com/equinix/terraform-provider-equinix/issues/36 and solved like this:

#availability_domain_1 = "iad-zone1-1"
#availability_domain_2 = "iad-zone2-1"
availability_domain_1 = "availability-domain-1"
availability_domain_2 = "availability-domain-2"

Still has the problem with the region name though.

anchala71 commented 1 year ago

@nickzxcv Upon looking at the error message, the vlan attachement key is invalid. Could you please check the pairing key format, here is the sample key "946h29b6-8649-4d45-9a08-0f1f4a7cd7ab/us-west1/1"

nickzxcv commented 1 year ago

@anchala71 I solved the key issue with the information from https://github.com/equinix/terraform-provider-equinix/issues/36 (I asked Google separately about that, why the zone names used with Equinix are not according to https://cloud.google.com/network-connectivity/docs/interconnect/concepts/choosing-colocation-facilities ) but the "inconsistent final plan" issue for the region name is still maybe a problem.