cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
789 stars 610 forks source link

Plugin crash importing cloudflare_dns_record in v5.0.0-alpha1 #4130

Closed rwgnr closed 1 month ago

rwgnr commented 1 month ago

Confirmation

Terraform and Cloudflare provider version

Terraform v1.8.3 on linux_amd64

Affected resource(s)

cloudflare_dns_record

Terraform configuration files

terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "5.0.0-alpha1"
    }
  }
}

provider "cloudflare" {}

resource "cloudflare_dns_record" "example" {
  zone_id = "foo"
  type    = "CNAME"
  name    = "www.example.com"
  content = "1.1.1.1"
  proxied = false
  comment = ""
  tags    = []
  ttl     = 86400
}

import {
  to = cloudflare_dns_record.example
  id = "foo/bar"
}

Link to debug output

https://gist.github.com/rwgnr/d1a97c5ed1335de1c2487057ca13a2c2

Panic output

2024-09-26T15:27:30.499-0500 [INFO] Terraform version: 1.8.3 2024-09-26T15:27:30.500-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.51.0 2024-09-26T15:27:30.500-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.20.0 2024-09-26T15:27:30.500-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1 2024-09-26T15:27:30.500-0500 [DEBUG] using github.com/zclconf/go-cty v1.14.3 2024-09-26T15:27:30.500-0500 [INFO] Go runtime version: go1.22.1 2024-09-26T15:27:30.500-0500 [INFO] CLI args: []string{"terraform", "plan"} 2024-09-26T15:27:30.500-0500 [DEBUG] Attempting to open CLI config file: /home/redacted/.terraformrc 2024-09-26T15:27:30.500-0500 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2024-09-26T15:27:30.500-0500 [INFO] Loading CLI configuration from /home/redacted/.terraform.d/credentials.tfrc.json 2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory /home/redacted/.terraform.d/plugins 2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory /home/redacted/.local/share/terraform/plugins 2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins 2024-09-26T15:27:30.503-0500 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins 2024-09-26T15:27:30.506-0500 [INFO] CLI command args: []string{"plan"} 2024-09-26T15:27:30.530-0500 [DEBUG] New state was assigned lineage "f597840f-220c-224c-fd06-efba301a9424" 2024-09-26T15:27:31.448-0500 [DEBUG] checking for provisioner in "." 2024-09-26T15:27:31.461-0500 [DEBUG] checking for provisioner in "/usr/bin" 2024-09-26T15:27:31.472-0500 [INFO] backend/local: starting Plan operation 2024-09-26T15:27:31.517-0500 [DEBUG] created provider logger: level=debug 2024-09-26T15:27:31.522-0500 [INFO] provider: configuring client automatic mTLS 2024-09-26T15:27:31.529-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 args=[".terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1"] 2024-09-26T15:27:31.539-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18956 2024-09-26T15:27:31.539-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 2024-09-26T15:27:32.488-0500 [INFO] provider.terraform-provider-cloudflare_v5.0.0-alpha1: configuring server automatic mTLS: timestamp=2024-09-26T15:27:32.488-0500 2024-09-26T15:27:32.506-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: plugin address: address=/tmp/plugin3197124194 network=unix timestamp=2024-09-26T15:27:32.505-0500 2024-09-26T15:27:32.506-0500 [DEBUG] provider: using plugin: version=6 2024-09-26T15:27:33.517-0500 [DEBUG] No provider meta schema returned 2024-09-26T15:27:33.527-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-09-26T15:27:33.533-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18956 2024-09-26T15:27:33.533-0500 [DEBUG] provider: plugin exited 2024-09-26T15:27:33.535-0500 [DEBUG] Building and walking validate graph 2024-09-26T15:27:33.537-0500 [DEBUG] ProviderTransformer: "cloudflare_dns_record.example" (terraform.NodeValidatableResource) needs provider["registry.terraform.io/cloudflare/cloudflare"] 2024-09-26T15:27:33.537-0500 [DEBUG] ReferenceTransformer: "cloudflare_dns_record.example" references: [] 2024-09-26T15:27:33.537-0500 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/cloudflare/cloudflare\"]" references: [] 2024-09-26T15:27:33.537-0500 [DEBUG] Starting graph walk: walkValidate 2024-09-26T15:27:33.548-0500 [DEBUG] created provider logger: level=debug 2024-09-26T15:27:33.548-0500 [INFO] provider: configuring client automatic mTLS 2024-09-26T15:27:33.551-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 args=[".terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1"] 2024-09-26T15:27:33.559-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18978 2024-09-26T15:27:33.560-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 2024-09-26T15:27:34.237-0500 [INFO] provider.terraform-provider-cloudflare_v5.0.0-alpha1: configuring server automatic mTLS: timestamp=2024-09-26T15:27:34.237-0500 2024-09-26T15:27:34.262-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: plugin address: address=/tmp/plugin33131820 network=unix timestamp=2024-09-26T15:27:34.262-0500 2024-09-26T15:27:34.262-0500 [DEBUG] provider: using plugin: version=6 2024-09-26T15:27:34.296-0500 [DEBUG] skipping FixUpBlockAttrs 2024-09-26T15:27:34.636-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-09-26T15:27:34.640-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18978 2024-09-26T15:27:34.640-0500 [DEBUG] provider: plugin exited 2024-09-26T15:27:34.640-0500 [INFO] backend/local: plan calling Plan 2024-09-26T15:27:34.640-0500 [DEBUG] Building and walking plan graph for NormalMode 2024-09-26T15:27:34.642-0500 [DEBUG] ProviderTransformer: "cloudflare_dns_record.example (expand)" (terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/cloudflare/cloudflare"] 2024-09-26T15:27:34.642-0500 [DEBUG] ReferenceTransformer: "cloudflare_dns_record.example (expand)" references: [] 2024-09-26T15:27:34.642-0500 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/cloudflare/cloudflare\"]" references: [] 2024-09-26T15:27:34.642-0500 [DEBUG] Starting graph walk: walkPlan 2024-09-26T15:27:34.652-0500 [DEBUG] created provider logger: level=debug 2024-09-26T15:27:34.652-0500 [INFO] provider: configuring client automatic mTLS 2024-09-26T15:27:34.654-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 args=[".terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1"] 2024-09-26T15:27:34.663-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18999 2024-09-26T15:27:34.663-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 2024-09-26T15:27:35.393-0500 [INFO] provider.terraform-provider-cloudflare_v5.0.0-alpha1: configuring server automatic mTLS: timestamp=2024-09-26T15:27:35.393-0500 2024-09-26T15:27:35.414-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: plugin address: network=unix address=/tmp/plugin3078070743 timestamp=2024-09-26T15:27:35.414-0500 2024-09-26T15:27:35.415-0500 [DEBUG] provider: using plugin: version=6 2024-09-26T15:27:35.552-0500 [DEBUG] Resource instance state not found for node "cloudflare_dns_record.example", instance cloudflare_dns_record.example 2024-09-26T15:27:35.552-0500 [DEBUG] ReferenceTransformer: "cloudflare_dns_record.example" references: [] cloudflare_dns_record.example: Preparing import... [id=foo/bar] 2024-09-26T15:27:35.917-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: panic: runtime error: invalid memory address or nil pointer dereference 2024-09-26T15:27:35.917-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x101121e] 2024-09-26T15:27:35.917-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1 2024-09-26T15:27:35.917-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: goroutine 45 [running]: 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record.(DNSRecordResource).ImportState(0xc0000d0790, {0x3393778, 0xc000d15920}, {{0xc000d26050?, 0x2f3c87d?}, {0x2d?}}, 0xc0000f9b00) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record/resource.go:231 +0x21e 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(Server).ImportResourceState(0xc000b96000, {0x3393778, 0xc000d15920}, 0xc0002259d0, 0xc000bc3688) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_importresourcestate.go:136 +0x7d4 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(Server).ImportResourceState(0xc000b96000, {0x3393778?, 0xc000d15830?}, 0xc000d157d0) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/proto6server/server_importresourcestate.go:47 +0x2a5 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(server).ImportResourceState(0xc0001fa1e0, {0x3393778?, 0xc000d14e70?}, 0xc00011c4b0) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:896 +0x265 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0x2e309a0, 0xc0001fa1e0}, {0x3393778, 0xc000d14e70}, 0xc000030880, 0x0) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:536 +0x1a6 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc.(Server).processUnaryRPC(0xc000b92000, {0x3393778, 0xc000d14de0}, {0x33f8800, 0xc000c6e000}, 0xc000d3d9e0, 0xc000b98060, 0x584e1d0, 0x0) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc.(Server).handleStream(0xc000b92000, {0x33f8800, 0xc000c6e000}, 0xc000d3d9e0) 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc.(Server).serveStreams.func2.1() 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: created by google.golang.org/grpc.(Server).serveStreams.func2 in goroutine 67 2024-09-26T15:27:35.926-0500 [DEBUG] provider.terraform-provider-cloudflare_v5.0.0-alpha1: google.golang.org/grpc@v1.63.2/server.go:1030 +0x125 2024-09-26T15:27:35.927-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-09-26T15:27:35.928-0500 [ERROR] plugin6.(*GRPCProvider).ImportResourceState: error="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-09-26T15:27:35.929-0500 [ERROR] vertex "cloudflare_dns_record.example" error: Plugin did not respond 2024-09-26T15:27:35.929-0500 [ERROR] vertex "cloudflare_dns_record.example (expand)" error: Plugin did not respond 2024-09-26T15:27:35.929-0500 [WARN] Planning encountered errors, so plan is not applyable 2024-09-26T15:27:35.929-0500 [INFO] backend/local: plan operation completed 2024-09-26T15:27:35.930-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.0.0-alpha1/linux_amd64/terraform-provider-cloudflare_v5.0.0-alpha1 pid=18999 error="exit status 2"

Planning failed. Terraform encountered an error while generating this plan.

╷ │ Error: Plugin did not respond │ │ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ImportResourceState call. The plugin logs may contain more details.

Stack trace from the terraform-provider-cloudflare_v5.0.0-alpha1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x101121e]

goroutine 45 [running]: github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record.(DNSRecordResource).ImportState(0xc0000d0790, {0x3393778, 0xc000d15920}, {{0xc000d26050?, 0x2f3c87d?}, {0x2d?}}, 0xc0000f9b00) github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record/resource.go:231 +0x21e github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(Server).ImportResourceState(0xc000b96000, {0x3393778, 0xc000d15920}, 0xc0002259d0, 0xc000bc3688) github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_importresourcestate.go:136 +0x7d4 github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(Server).ImportResourceState(0xc000b96000, {0x3393778?, 0xc000d15830?}, 0xc000d157d0)
github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/proto6server/server_importresourcestate.go:47 +0x2a5 github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(
server).ImportResourceState(0xc0001fa1e0, {0x3393778?, 0xc000d14e70?}, 0xc00011c4b0) github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:896 +0x265 github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0x2e309a0, 0xc0001fa1e0}, {0x3393778, 0xc000d14e70}, 0xc000030880, 0x0) github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:536 +0x1a6 google.golang.org/grpc.(Server).processUnaryRPC(0xc000b92000, {0x3393778, 0xc000d14de0}, {0x33f8800, 0xc000c6e000}, 0xc000d3d9e0, 0xc000b98060, 0x584e1d0, 0x0) google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8 google.golang.org/grpc.(Server).handleStream(0xc000b92000, {0x33f8800, 0xc000c6e000}, 0xc000d3d9e0) google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b google.golang.org/grpc.(Server).serveStreams.func2.1() google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b created by google.golang.org/grpc.(Server).serveStreams.func2 in goroutine 67 google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-cloudflare_v5.0.0-alpha1 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

2024-09-26T15:27:35.939-0500 [DEBUG] provider: plugin exited

Expected output

Import of the DNS record into state

Actual output

Plugin crashed

Steps to reproduce

  1. Create DNS record in Cloudflare outside of Terraform
  2. Attempt to import that existing DNS record into Terraform

Additional factoids

No response

References

No response

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 1 month ago

importing is not yet fully supported in the alpha. it will be improved as we get closer to general availability.