equinix / terraform-provider-equinix

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

[Bug]: Provider produced inconsistent final plan #424

Open mwardbopp opened 1 year ago

mwardbopp commented 1 year ago

Terraform Version

1.6.2

Equinix Provider Version

1.18.0

Effected Terraform Resources

equinix_network_file equinix_network_device

Terraform Config Files

resource "aviatrix_edge_equinix" "primary_gw" {
  account_name           = "equinix"
  gw_name                = var.equinix_gw_name
  site_id                = var.equinix_site_id
  ztp_file_download_path = var.path
  local_as_number        = var.aws_dx_vif_customer_asn
  # enable_management_over_private_network = true

  interfaces {
    name          = "eth0"
    type          = "WAN"
    ip_address    = "169.254.0.2/30"
    gateway_ip    = "169.254.0.1"
  }

  interfaces {
    name       = "eth1"
    type       = "LAN"
    ip_address = "192.168.100.1/24"
  }
  # interfaces {
  #   name       = "eth2"
  #   type       = "MANAGEMENT"
  #   enable_dhcp = false
  #   ip_address = "192.168.100.1/24"
  #   gateway_ip    = "192.168.100.254"
  # }
}

resource "equinix_network_acl_template" "equinix-acl-template" {
  name        = "mwb-equinix-avx-acl"
  description = "AVX Equinix ACL"
  inbound_rule {
    subnet  = "34.250.247.211/32"
    protocol = "TCP"
    src_port = "any"
    dst_port = "any"
    description = "Controller IP"
  }
  inbound_rule {
    subnet  = "33.248.175.208/32"
    protocol = "TCP"
    src_port = "any"
    dst_port = "any"
    description = "CoPilot IP"
  }
  inbound_rule {
    subnet  = "8.8.8.8/32"
    protocol = "UDP"
    src_port = "any"
    dst_port = "any"
    description = "DNS IP"
  }
  inbound_rule {
    subnet  = "8.8.4.4/32"
    protocol = "UDP"
    src_port = "any"
    dst_port = "any"
    description = "DNS IP 2"
  }
  inbound_rule {
    subnet  = "169.254.0.0/30"
    protocol = "IP"
    src_port = "any"
    dst_port = "any"
    description = "dx aws router"
  }
  inbound_rule {
    subnet  = "169.254.0.0/30"
    protocol = "TCP"
    src_port = "any"
    dst_port = "any"
    description = "dx aws router"
  }
}

# Create self configured single Aviatrix device with cloud init file

data "equinix_network_account" "ny" {
  metro_code = "NY"
  name = "Aviatrix"
}

resource "equinix_network_file" "aviatrix-cloudinit-file" {
  file_name = "${aviatrix_edge_equinix.primary_gw.gw_name}-${aviatrix_edge_equinix.primary_gw.site_id}-cloud-init.txt"
  content = file("${var.equinix_gw_name}-${var.equinix_site_id}-cloud-init.txt")
  # content   = data.local_file.cloud_init_file.content
  metro_code = data.equinix_network_account.ny.metro_code
  device_type_code = "AVIATRIX_EDGE"
  process_type = "CLOUD_INIT"
  self_managed = true
  byol = true
  depends_on = [ aviatrix_edge_equinix.primary_gw ]
  # lifecycle {
  #   ignore_changes = [file_name]
  # }
}

resource "equinix_network_device" "aviatrix-single" {
  name            = "mwb-ny-tf-avx"
  metro_code      = data.equinix_network_account.ny.metro_code
  type_code       = "AVIATRIX_EDGE_10"
  self_managed    = true
  byol            = true
  package_code    = "STD"
  notifications   = ["mward-bopp@redacted"]
  term_length     = 1
  account_number  = data.equinix_network_account.ny.number
  version         = "7.1"
  core_count      = 2
  cloud_init_file_id = equinix_network_file.aviatrix-cloudinit-file.uuid
  acl_template_id = equinix_network_acl_template.equinix-acl-template.id
  lifecycle {
    ignore_changes = [cloud_init_file_id]
  }
}

Debug Output

aviatrix_edge_equinix.primary_gw: Creating...
2023-10-25T16:19:22.510+0100 [INFO]  Starting apply for aviatrix_edge_equinix.primary_gw
2023-10-25T16:19:22.511+0100 [DEBUG] aviatrix_edge_equinix.primary_gw: applying the planned Create change
equinix_network_acl_template.equinix-acl-template: Creating...
2023-10-25T16:19:22.948+0100 [INFO]  Starting apply for equinix_network_acl_template.equinix-acl-template
2023-10-25T16:19:22.949+0100 [DEBUG] equinix_network_acl_template.equinix-acl-template: applying the planned Create change
2023-10-25T16:19:22.951+0100 [INFO]  provider.terraform-provider-equinix_v1.18.0: 2023/10/25 16:19:22 [DEBUG] setting computed for "device_details" from ComputedKeys: timestamp="2023-10-25T16:19:22.951+0100"
2023-10-25T16:19:22.952+0100 [INFO]  provider.terraform-provider-equinix_v1.18.0: 2023/10/25 16:19:22 [DEBUG] Equinix API Request Details:
---[ REQUEST ]---------------------------------------
POST /ne/v1/aclTemplates HTTP/1.1
Host: api.equinix.com
User-Agent: HashiCorp Terraform/1.6.2 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-equinix/1.18.0 equinix/ecx-go
Content-Length: 763
Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip

{
 "name": "mwb-equinix-avx-acl",
 "description": "AVX Equinix ACL",
 "inboundRules": [
  {
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "x.x.x.x/32",
   "seqNo": 1,
   "description": "Controller IP"
  },
  {
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "x.x.x.x/32
   "seqNo": 2,
   "description": "CoPilot IP"
  },
  {
   "protocol": "UDP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "8.8.8.8/32",
   "seqNo": 3,
   "description": "DNS IP"
  },
  {
   "protocol": "UDP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "8.8.4.4/32",
   "seqNo": 4,
   "description": "DNS IP 2"
  },
  {
   "protocol": "IP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "169.254.0.0/30",
   "seqNo": 5,
   "description": "dx aws router"
  },
  {
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any",
   "subnet": "169.254.0.0/30",
   "seqNo": 6,
   "description": "dx aws router"
  }
 ]
}
-----------------------------------------------------: timestamp="2023-10-25T16:19:22.952+0100"
2023-10-25T16:19:24.002+0100 [INFO]  provider.terraform-provider-equinix_v1.18.0: 2023/10/25 16:19:24 [DEBUG] Equinix API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 201 Created
Content-Length: 0
Connection: keep-alive
Date: Wed, 25 Oct 2023 15:19:24 GMT
Location: /v1/aclTemplates/55449241-7cbb-4b7f-999e-366bb3b426a6
Server: istio-envoy
X-Apigee-Dp-Color: 174
X-Apigee-Environment: extprod
X-Apigee-Message-Id: 0a25024f-3543-4d3f-9a90-6d518af6cc5c
X-Apigee-Organization: eqx-apg-prod
X-Apigee-Proxy: /organizations/eqx-apg-prod/environments/extprod/apiproxies/Network_Edge_Apis/revisions/9
X-Apigee-Proxy-Basepath: /ne/v1
X-Apigee-Region: us-west1
X-Apigee-Target-Latency: 820
X-Envoy-Upstream-Service-Time: 836
X-Request-Id: 0a25024f-3543-4d3f-9a90-6d518af6cc5c

-----------------------------------------------------: timestamp="2023-10-25T16:19:24.002+0100"
2023-10-25T16:19:24.003+0100 [INFO]  provider.terraform-provider-equinix_v1.18.0: 2023/10/25 16:19:24 [DEBUG] Equinix API Request Details:
---[ REQUEST ]---------------------------------------
GET /ne/v1/aclTemplates/55449241-7cbb-4b7f-999e-366bb3b426a6 HTTP/1.1
Host: api.equinix.com
User-Agent: HashiCorp Terraform/1.6.2 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-equinix/1.18.0 equinix/ecx-go
Accept: application/json
Accept-Encoding: gzip

-----------------------------------------------------: timestamp="2023-10-25T16:19:24.003+0100"
2023-10-25T16:19:24.511+0100 [INFO]  provider.terraform-provider-equinix_v1.18.0: 2023/10/25 16:19:24 [DEBUG] Equinix API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Date: Wed, 25 Oct 2023 15:19:24 GMT
Server: istio-envoy
Vary: Accept-Encoding
X-Apigee-Dp-Color: 174
X-Apigee-Environment: extprod
X-Apigee-Message-Id: 91a192b7-ae6c-4fd4-92c5-e177d0c6db19
X-Apigee-Organization: eqx-apg-prod
X-Apigee-Proxy: /organizations/eqx-apg-prod/environments/extprod/apiproxies/Network_Edge_Apis/revisions/9
X-Apigee-Proxy-Basepath: /ne/v1
X-Apigee-Region: us-west1
X-Apigee-Target-Latency: 308
X-Envoy-Upstream-Service-Time: 320
X-Request-Id: 91a192b7-ae6c-4fd4-92c5-e177d0c6db19

{
 "name": "mwb-equinix-avx-acl",
 "uuid": "55449241-7cbb-4b7f-999e-366bb3b426a6",
 "description": "AVX Equinix ACL",
 "projectId": "a981b91e-dd14-4fb3-b477-ae90ebd9c213",
 "projectName": "Project-26510",
 "inboundRules": [
  {
   "seqNo": 1,
   "subnets": [
    "x.x.x.x/32"
   ],
   "description": "Controller IP",
   "subnet": "x.x.x.x/32",
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any"
  },
  {
   "seqNo": 2,
   "subnets": [
    "x.x.x.x/32"
   ],
   "description": "CoPilot IP",
   "subnet": "x.x.x.x/32",
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any"
  },
  {
   "seqNo": 3,
   "subnets": [
    "8.8.8.8/32"
   ],
   "description": "DNS IP",
   "subnet": "8.8.8.8/32",
   "protocol": "UDP",
   "srcPort": "any",
   "dstPort": "any"
  },
  {
   "seqNo": 4,
   "subnets": [
    "8.8.4.4/32"
   ],
   "description": "DNS IP 2",
   "subnet": "8.8.4.4/32",
   "protocol": "UDP",
   "srcPort": "any",
   "dstPort": "any"
  },
  {
   "seqNo": 5,
   "subnets": [
    "169.254.0.0/30"
   ],
   "description": "dx aws router",
   "subnet": "169.254.0.0/30",
   "protocol": "IP",
   "srcPort": "any",
   "dstPort": "any"
  },
  {
   "seqNo": 6,
   "subnets": [
    "169.254.0.0/30"
   ],
   "description": "dx aws router",
   "subnet": "169.254.0.0/30",
   "protocol": "TCP",
   "srcPort": "any",
   "dstPort": "any"
  }
 ],
 "metroName": "",
 "metroCode": "",
 "virtualDeviceDetails": [],
 "createdBy": "mward-bopp@redacted1",
 "createdDate": "2023-10-25T15:19:23.789Z"
}
-----------------------------------------------------: timestamp="2023-10-25T16:19:24.511+0100"
equinix_network_acl_template.equinix-acl-template: Creation complete after 2s [id=55449241-7cbb-4b7f-999e-366bb3b426a6]
2023-10-25T16:19:24.544+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-10-25T16:19:26.259+0100 [WARN]  Provider "provider[\"registry.terraform.io/aviatrixsystems/aviatrix\"]" produced an unexpected new value for aviatrix_edge_equinix.primary_gw, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .rx_queue_size: was null, but now cty.StringVal("")
      - .secondary_dns_server_ip: was null, but now cty.StringVal("")
      - .dns_server_ip: was null, but now cty.StringVal("")
aviatrix_edge_equinix.primary_gw: Creation complete after 3s [id=equinix-edge-ny]
2023-10-25T16:19:26.276+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-10-25T16:19:26.277+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-10-25T16:19:26.278+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/aviatrixsystems/aviatrix/3.1.2/darwin_arm64/terraform-provider-aviatrix_v3.1.2 pid=19662
2023-10-25T16:19:26.278+0100 [DEBUG] provider: plugin exited
2023-10-25T16:19:26.281+0100 [ERROR] vertex "equinix_network_file.aviatrix-cloudinit-file" error: Provider produced inconsistent final plan
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for equinix_network_file.aviatrix-cloudinit-file to include new values learned so far during apply,
│ provider "registry.terraform.io/equinix/equinix" produced an invalid new value for .content: inconsistent values for sensitive
│ attribute.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
2023-10-25T16:19:26.296+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-10-25T16:19:26.297+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/equinix/equinix/1.18.0/darwin_arm64/terraform-provider-equinix_v1.18.0 pid=19663
2023-10-25T16:19:26.297+0100 [DEBUG] provider: plugin exited

Panic Output

No response

Expected Behavior

Not require doing two "terraform apply" to get this to work

Actual Behavior

Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for equinix_network_file.aviatrix-cloudinit-file to include new values learned so far during apply,
│ provider "registry.terraform.io/equinix/equinix" produced an invalid new value for .content: inconsistent values for sensitive
│ attribute.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Steps to Reproduce

1st terraform apply

mwardbopp commented 11 months ago

I was able to workaround this by using a local_file and then using that content for the network_file

data "local_file" "ztp-primary_gw" {
  filename = "${aviatrix_edge_equinix.primary_gw.gw_name}-${aviatrix_edge_equinix.primary_gw.site_id}-cloud-init.txt"  # Path to your local file
}

resource "equinix_network_file" "aviatrix-cloudinit-file" {
  file_name = "ztp-cloud-init.txt"
  content = data.local_file.ztp-primary_gw.content
  metro_code = "NY"
  device_type_code = "AVIATRIX_EDGE"
  process_type = "CLOUD_INIT"
  self_managed = true
  byol = true
  depends_on = [ aviatrix_edge_equinix.primary_gw ]
  lifecycle {
    ignore_changes = [content]
  }
}