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

import cloudflare_record of type SRV results in empty data-array in tfstate #1714

Closed
2 tasks done
Iridias opened this issue Jun 20, 2022 · 1 comment · Fixed by #1942
Closed
2 tasks done

import cloudflare_record of type SRV results in empty data-array in tfstate #1714

Iridias opened this issue Jun 20, 2022 · 1 comment · Fixed by #1942
Labels
kind/bug Categorizes issue or PR as related to a bug. service/dns Categorizes issue or PR as related to the DNS service. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@Iridias
Copy link

Iridias commented Jun 20, 2022

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.2.2
Cloudflare provider v3.17.0

Affected resource(s)

cloudflare_record

Terraform configuration files

resource "cloudflare_record" "terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8" {
  name     = "_sip._tls.extern"
  priority = 100
  proxied  = false
  ttl      = 86400
  type     = "SRV"
  zone_id  = "00000000000000000000000000000000"
  data {
    name     = "extern.test.domain"
    port     = 443
    priority = 100
    proto    = "_tls"
    service  = "_sip"
    target   = "sipdir.online.lync.com"
    weight   = 1
  }
}

Debug output

2022-06-20T17:46:01.196+0200 [DEBUG] pruning unused provider["registry.terraform.io/hashicorp/azurerm"]
2022-06-20T17:46:01.198+0200 [DEBUG] created provider logger: level=debug
2022-06-20T17:46:01.198+0200 [INFO]  provider: configuring client automatic mTLS
2022-06-20T17:46:01.212+0200 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 args=[.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0]
2022-06-20T17:46:01.213+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 pid=43311
2022-06-20T17:46:01.213+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0
2022-06-20T17:46:01.216+0200 [INFO]  provider.terraform-provider-cloudflare_v3.17.0: configuring server automatic mTLS: timestamp=2022-06-20T17:46:01.216+0200
2022-06-20T17:46:01.231+0200 [DEBUG] provider: using plugin: version=5
2022-06-20T17:46:01.231+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: plugin address: address=/tmp/plugin149258695 network=unix timestamp=2022-06-20T17:46:01.231+0200
2022-06-20T17:46:01.267+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-06-20T17:46:01.268+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 pid=43311
2022-06-20T17:46:01.268+0200 [DEBUG] provider: plugin exited

2022-06-20T17:46:01.277+0200 [DEBUG] ReferenceTransformer: "var.cf_api_key" references: []
2022-06-20T17:46:01.299+0200 [DEBUG] Starting graph walk: walkImport
2022-06-20T17:46:01.302+0200 [DEBUG] created provider logger: level=debug
2022-06-20T17:46:01.302+0200 [INFO]  provider: configuring client automatic mTLS
2022-06-20T17:46:01.328+0200 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 args=[.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0]
2022-06-20T17:46:01.328+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 pid=43324
2022-06-20T17:46:01.328+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0
2022-06-20T17:46:01.332+0200 [INFO]  provider.terraform-provider-cloudflare_v3.17.0: configuring server automatic mTLS: timestamp=2022-06-20T17:46:01.331+0200
2022-06-20T17:46:01.346+0200 [DEBUG] provider: using plugin: version=5
2022-06-20T17:46:01.346+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: plugin address: address=/tmp/plugin1348911508 network=unix timestamp=2022-06-20T17:46:01.346+0200
2022-06-20T17:46:01.382+0200 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/cloudflare/cloudflare\"]" changed the config value, but that value is unused
module.test_module.cloudflare_record.terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8: Importing from ID "00000000000000000000000000000000/a78d9dd5beb0bce415a86a763e0c24c8"...
2022-06-20T17:46:01.383+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Request Details:
---[ REQUEST ]---------------------------------------
GET /client/v4/zones/00000000000000000000000000000000/dns_records/a78d9dd5beb0bce415a86a763e0c24c8 HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.2.2 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Type: application/json
X-Auth-Email: account@mail.invalid
X-Auth-Key: 00000000000000000000000000000000
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2022-06-20T17:46:01.383+0200
2022-06-20T17:46:02.314+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Cf-Cache-Status: DYNAMIC
Cf-Ray: 71e5a2872e849bfb-FRA
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:02 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU56Rb8iNWZVUvXhqooDeYyyq3s; SameSite=Lax; path=/; expires=Mon, 20-Jun-22 18:16:03 GMT; HttpOnly
Set-Cookie: __cfruid=ea000912b6f9fe0b997b38dc049cfc02ab74f672-1655739962; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
Vary: Accept-Encoding
X-Envoy-Upstream-Service-Time: 13

{
 "result": {
  "id": "a78d9dd5beb0bce415a86a763e0c24c8",
  "zone_id": "00000000000000000000000000000000",
  "zone_name": "test.domain",
  "name": "_sip._tls.extern.test.domain",
  "type": "SRV",
  "content": "1\t443\tsipdir.online.lync.com",
  "priority": 100,
  "proxiable": false,
  "proxied": false,
  "ttl": 86400,
  "locked": false,
  "data": {
   "name": "extern.test.domain",
   "port": 443,
   "priority": 100,
   "proto": "_tls",
   "service": "_sip",
   "target": "sipdir.online.lync.com",
   "weight": 1
  },
  "meta": {
   "auto_added": false,
   "managed_by_apps": false,
   "managed_by_argo_tunnel": false,
   "source": "primary"
  },
  "created_on": "2019-03-18T16:37:55.713709Z",
  "modified_on": "2019-03-18T16:37:55.713709Z"
 },
 "success": true,
 "errors": [],
 "messages": []
}
-----------------------------------------------------: timestamp=2022-06-20T17:46:02.314+0200
2022-06-20T17:46:02.314+0200 [INFO]  provider.terraform-provider-cloudflare_v3.17.0: Found record: _sip._tls.extern.test.domain: @module=cloudflare tf_req_id=44b86c12-7fe1-a94f-762f-f1444c1c390d tf_resource_type=cloudflare_record tf_rpc=ImportResourceState @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/provider/resource_cloudflare_record.go:362 tf_provider_addr=registry.terraform.io/cloudflare/cloudflare timestamp=2022-06-20T17:46:02.314+0200
2022-06-20T17:46:02.314+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Request Details:
---[ REQUEST ]---------------------------------------
GET /client/v4/zones/00000000000000000000000000000000/dns_records/a78d9dd5beb0bce415a86a763e0c24c8 HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.2.2 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Type: application/json
X-Auth-Email: account@mail.invalid
X-Auth-Key: 00000000000000000000000000000000
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2022-06-20T17:46:02.314+0200
2022-06-20T17:46:03.175+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Cf-Cache-Status: DYNAMIC
Cf-Ray: 71e5a28cc89d6997-FRA
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:03 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU56Rb8iNWZVUvXhqyVtfMoUSKP; SameSite=Lax; path=/; expires=Mon, 20-Jun-22 18:16:04 GMT; HttpOnly
Set-Cookie: __cfruid=220a61019b36dff394bdef23d1fdf061753fbb7e-1655739963; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
Vary: Accept-Encoding
X-Envoy-Upstream-Service-Time: 23

{
 "result": {
  "id": "a78d9dd5beb0bce415a86a763e0c24c8",
  "zone_id": "00000000000000000000000000000000",
  "zone_name": "test.domain",
  "name": "_sip._tls.extern.test.domain",
  "type": "SRV",
  "content": "1\t443\tsipdir.online.lync.com",
  "priority": 100,
  "proxiable": false,
  "proxied": false,
  "ttl": 86400,
  "locked": false,
  "data": {
   "name": "extern.test.domain",
   "port": 443,
   "priority": 100,
   "proto": "_tls",
   "service": "_sip",
   "target": "sipdir.online.lync.com",
   "weight": 1
  },
  "meta": {
   "auto_added": false,
   "managed_by_apps": false,
   "managed_by_argo_tunnel": false,
   "source": "primary"
  },
  "created_on": "2019-03-18T16:37:55.713709Z",
  "modified_on": "2019-03-18T16:37:55.713709Z"
 },
 "success": true,
 "errors": [],
 "messages": []
}
-----------------------------------------------------: timestamp=2022-06-20T17:46:03.175+0200
2022-06-20T17:46:03.175+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Data found in config: []interface {}{}: tf_provider_addr=registry.terraform.io/cloudflare/cloudflare tf_req_id=44b86c12-7fe1-a94f-762f-f1444c1c390d tf_resource_type=cloudflare_record @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/provider/resource_cloudflare_record.go:198 @module=cloudflare tf_rpc=ImportResourceState timestamp=2022-06-20T17:46:03.175+0200
2022-06-20T17:46:03.175+0200 [ERROR] provider.terraform-provider-cloudflare_v3.17.0: setting state: data: '': source data must be an array or slice, got map: timestamp=2022-06-20T17:46:03.175+0200
module.test_module.cloudflare_record.terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8: Import prepared!
  Prepared cloudflare_record for import
module.test_module.cloudflare_record.terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8: Refreshing state... [id=a78d9dd5beb0bce415a86a763e0c24c8]
2022-06-20T17:46:03.177+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Request Details:
---[ REQUEST ]---------------------------------------
GET /client/v4/zones/00000000000000000000000000000000/dns_records/a78d9dd5beb0bce415a86a763e0c24c8 HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.2.2 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Type: application/json
X-Auth-Email: account@mail.invalid
X-Auth-Key: 00000000000000000000000000000000
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2022-06-20T17:46:03.177+0200
2022-06-20T17:46:04.014+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Cloudflare API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Cf-Cache-Status: DYNAMIC
Cf-Ray: 71e5a2922a9d9124-FRA
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:03 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU56Rb8iNWZVUvXhr9CZgAcy3au; SameSite=Lax; path=/; expires=Mon, 20-Jun-22 18:16:04 GMT; HttpOnly
Set-Cookie: __cfruid=220a61019b36dff394bdef23d1fdf061753fbb7e-1655739963; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
Vary: Accept-Encoding
X-Envoy-Upstream-Service-Time: 14

{
 "result": {
  "id": "a78d9dd5beb0bce415a86a763e0c24c8",
  "zone_id": "00000000000000000000000000000000",
  "zone_name": "test.domain",
  "name": "_sip._tls.extern.test.domain",
  "type": "SRV",
  "content": "1\t443\tsipdir.online.lync.com",
  "priority": 100,
  "proxiable": false,
  "proxied": false,
  "ttl": 86400,
  "locked": false,
  "data": {
   "name": "extern.test.domain",
   "port": 443,
   "priority": 100,
   "proto": "_tls",
   "service": "_sip",
   "target": "sipdir.online.lync.com",
   "weight": 1
  },
  "meta": {
   "auto_added": false,
   "managed_by_apps": false,
   "managed_by_argo_tunnel": false,
   "source": "primary"
  },
  "created_on": "2019-03-18T16:37:55.713709Z",
  "modified_on": "2019-03-18T16:37:55.713709Z"
 },
 "success": true,
 "errors": [],
 "messages": []
}
-----------------------------------------------------: timestamp=2022-06-20T17:46:04.014+0200
2022-06-20T17:46:04.014+0200 [DEBUG] provider.terraform-provider-cloudflare_v3.17.0: Data found in config: []interface {}{}: tf_resource_type=cloudflare_record @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/provider/resource_cloudflare_record.go:198 @module=cloudflare tf_provider_addr=registry.terraform.io/cloudflare/cloudflare tf_req_id=5b5e5ad9-3a46-515f-85b5-b805df5a8c4c tf_rpc=ReadResource timestamp=2022-06-20T17:46:04.014+0200
2022-06-20T17:46:04.014+0200 [ERROR] provider.terraform-provider-cloudflare_v3.17.0: setting state: data: '': source data must be an array or slice, got map: timestamp=2022-06-20T17:46:04.014+0200
2022-06-20T17:46:04.016+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-06-20T17:46:04.017+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/3.17.0/linux_amd64/terraform-provider-cloudflare_v3.17.0 pid=43324
2022-06-20T17:46:04.017+0200 [DEBUG] provider: plugin exited
2022-06-20T17:46:04.017+0200 [INFO]  Writing state output to:
2022-06-20T17:46:04.017+0200 [DEBUG] Azure Backend Request: 
HEAD /tfstate/cloudflare_config.test_module.test.tfstate HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.037+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate: 
HTTP/1.1 200 OK
Content-Length: 155
Accept-Ranges: bytes
Content-Md5: z6v4yZ6ThsGRpT9F6I66+Q==
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3F9F05E36"
Last-Modified: Mon, 20 Jun 2022 15:46:01 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Access-Tier: Hot
X-Ms-Access-Tier-Inferred: true
X-Ms-Blob-Type: BlockBlob
X-Ms-Creation-Time: Mon, 20 Jun 2022 15:35:47 GMT
X-Ms-Lease-Duration: infinite
X-Ms-Lease-State: leased
X-Ms-Lease-Status: locked
X-Ms-Meta-Terraformlockid: eyJJRCI6ImY4MDllZDFlLTNiZWQtOTMwZC0yODY0LTgwODljYzk5Yzk1ZiIsIk9wZXJhdGlvbiI6Ik9wZXJhdGlvblR5cGVJbnZhbGlkIiwiSW5mbyI6IiIsIldobyI6ImlyaWRpYXNAaG9tZXN0ZWFkIiwiVmVyc2lvbiI6IjEuMi4yIiwiQ3JlYXRlZCI6IjIwMjItMDYtMjBUMTU6NDY6MDEuMDQzMDc3NjYxWiIsIlBhdGgiOiJ0ZnN0YXRlL2Nsb3VkZmxhcmVfY29uZmlnLnZoYl9kZS50ZXN0LnRmc3RhdGUifQ==
X-Ms-Request-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Server-Encrypted: true
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.037+0200 [DEBUG] Azure Backend Request: 
PUT /tfstate/cloudflare_config.test_module.test.tfstate HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
Content-Length: 1621
X-Ms-Blob-Content-Type: application/json
X-Ms-Blob-Type: BlockBlob
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Meta-Terraformlockid: eyJJRCI6ImY4MDllZDFlLTNiZWQtOTMwZC0yODY0LTgwODljYzk5Yzk1ZiIsIk9wZXJhdGlvbiI6Ik9wZXJhdGlvblR5cGVJbnZhbGlkIiwiSW5mbyI6IiIsIldobyI6ImlyaWRpYXNAaG9tZXN0ZWFkIiwiVmVyc2lvbiI6IjEuMi4yIiwiQ3JlYXRlZCI6IjIwMjItMDYtMjBUMTU6NDY6MDEuMDQzMDc3NjYxWiIsIlBhdGgiOiJ0ZnN0YXRlL2Nsb3VkZmxhcmVfY29uZmlnLnZoYl9kZS50ZXN0LnRmc3RhdGUifQ==
X-Ms-Version: 2018-11-09
Accept-Encoding: gzip

{
  "version": 4,
  "terraform_version": "1.2.2",
  "serial": 1,
  "lineage": "8a29a8e6-ea25-dae8-af96-12240900b1df",
  "outputs": {},
  "resources": [
    {
      "module": "module.test_module",
      "mode": "managed",
      "type": "cloudflare_record",
      "name": "terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8",
      "provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
      "instances": [
        {
          "schema_version": 2,
          "attributes": {
            "allow_overwrite": null,
            "created_on": "2019-03-18T16:37:55.713709Z",
            "data": [],
            "hostname": "_sip._tls.extern.test.domain",
            "id": "a78d9dd5beb0bce415a86a763e0c24c8",
            "metadata": {
              "auto_added": "false",
              "managed_by_apps": "false",
              "managed_by_argo_tunnel": "false",
              "source": "primary"
            },
            "modified_on": "2019-03-18T16:37:55.713709Z",
            "name": "_sip._tls.extern",
            "priority": 100,
            "proxiable": false,
            "proxied": false,
            "timeouts": {
              "create": null,
              "update": null
            },
            "ttl": 86400,
            "type": "SRV",
            "value": "1\t443\tsipdir.online.lync.com",
            "zone_id": "00000000000000000000000000000000"
          },
          "sensitive_attributes": [],
          "private": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
      ]
    }
  ]
}
2022-06-20T17:46:04.063+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate: 
HTTP/1.1 201 Created
Content-Length: 0
Content-Md5: RU2TC8bO5U9yEVdZj29PgQ==
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3FBAF554C"
Last-Modified: Mon, 20 Jun 2022 15:46:04 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Request-Server-Encrypted: true
X-Ms-Version: 2018-11-09

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

2022-06-20T17:46:04.063+0200 [DEBUG] Azure Backend Request: 
HEAD /tfstate/cloudflare_config.test_module.test.tfstate HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.085+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate: 
HTTP/1.1 200 OK
Content-Length: 1621
Accept-Ranges: bytes
Content-Md5: RU2TC8bO5U9yEVdZj29PgQ==
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3FBAF554C"
Last-Modified: Mon, 20 Jun 2022 15:46:04 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Access-Tier: Hot
X-Ms-Access-Tier-Inferred: true
X-Ms-Blob-Type: BlockBlob
X-Ms-Creation-Time: Mon, 20 Jun 2022 15:35:47 GMT
X-Ms-Lease-Duration: infinite
X-Ms-Lease-State: leased
X-Ms-Lease-Status: locked
X-Ms-Meta-Terraformlockid: eyJJRCI6ImY4MDllZDFlLTNiZWQtOTMwZC0yODY0LTgwODljYzk5Yzk1ZiIsIk9wZXJhdGlvbiI6Ik9wZXJhdGlvblR5cGVJbnZhbGlkIiwiSW5mbyI6IiIsIldobyI6ImlyaWRpYXNAaG9tZXN0ZWFkIiwiVmVyc2lvbiI6IjEuMi4yIiwiQ3JlYXRlZCI6IjIwMjItMDYtMjBUMTU6NDY6MDEuMDQzMDc3NjYxWiIsIlBhdGgiOiJ0ZnN0YXRlL2Nsb3VkZmxhcmVfY29uZmlnLnZoYl9kZS50ZXN0LnRmc3RhdGUifQ==
X-Ms-Request-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Server-Encrypted: true
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.085+0200 [DEBUG] Azure Backend Request: 
HEAD /tfstate/cloudflare_config.test_module.test.tfstate HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.106+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate: 
HTTP/1.1 200 OK
Content-Length: 1621
Accept-Ranges: bytes
Content-Md5: RU2TC8bO5U9yEVdZj29PgQ==
Content-Type: application/json
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3FBAF554C"
Last-Modified: Mon, 20 Jun 2022 15:46:04 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Access-Tier: Hot
X-Ms-Access-Tier-Inferred: true
X-Ms-Blob-Type: BlockBlob
X-Ms-Creation-Time: Mon, 20 Jun 2022 15:35:47 GMT
X-Ms-Lease-Duration: infinite
X-Ms-Lease-State: leased
X-Ms-Lease-Status: locked
X-Ms-Meta-Terraformlockid: eyJJRCI6ImY4MDllZDFlLTNiZWQtOTMwZC0yODY0LTgwODljYzk5Yzk1ZiIsIk9wZXJhdGlvbiI6Ik9wZXJhdGlvblR5cGVJbnZhbGlkIiwiSW5mbyI6IiIsIldobyI6ImlyaWRpYXNAaG9tZXN0ZWFkIiwiVmVyc2lvbiI6IjEuMi4yIiwiQ3JlYXRlZCI6IjIwMjItMDYtMjBUMTU6NDY6MDEuMDQzMDc3NjYxWiIsIlBhdGgiOiJ0ZnN0YXRlL2Nsb3VkZmxhcmVfY29uZmlnLnZoYl9kZS50ZXN0LnRmc3RhdGUifQ==
X-Ms-Request-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Server-Encrypted: true
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.106+0200 [DEBUG] Azure Backend Request: 
PUT /tfstate/cloudflare_config.test_module.test.tfstate?comp=metadata HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
Content-Length: 0
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09
Accept-Encoding: gzip
2022-06-20T17:46:04.129+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate?comp=metadata: 
HTTP/1.1 200 OK
Content-Length: 0
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3FBB9B3F6"
Last-Modified: Mon, 20 Jun 2022 15:46:04 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id: d554fc59-d01e-0007-2ebc-845ae2000000
X-Ms-Request-Server-Encrypted: true
X-Ms-Version: 2018-11-09
2022-06-20T17:46:04.129+0200 [DEBUG] Azure Backend Request: 
PUT /tfstate/cloudflare_config.test_module.test.tfstate?comp=lease HTTP/1.1
Host: dummyterraformstate.blob.core.windows.net
User-Agent: Terraform/1.2.2
Content-Length: 0
X-Ms-Date: Mon, 20 Jun 2022 15:46:04 GMT
X-Ms-Lease-Action: release
X-Ms-Lease-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09
Accept-Encoding: gzip
2022-06-20T17:46:04.150+0200 [DEBUG] Azure Backend Response for https://dummyterraformstate.blob.core.windows.net/tfstate/cloudflare_config.test_module.test.tfstate?comp=lease: 
HTTP/1.1 200 OK
Content-Length: 0
Date: Mon, 20 Jun 2022 15:46:03 GMT
Etag: "0x8DA52D3FBB9B3F6"
Last-Modified: Mon, 20 Jun 2022 15:46:04 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id: 00000000-0000-0000-0000-000000000000
X-Ms-Version: 2018-11-09


Panic output

No response

Expected output

I expect the data-map to be properly imported into the terraform-state file.
The result should look like this (as it will/would when creating the resource):

{
  "version": 4,
  "terraform_version": "1.2.2",
  "serial": 1,
  "lineage": "51fcb918-7e52-7ea9-45f7-766e218f60ba",
  "outputs": {},
  "resources": [
    {
      "module": "module.test_module",
      "mode": "managed",
      "type": "cloudflare_record",
      "name": "terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8",
      "provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
      "instances": [
        {
          "schema_version": 2,
          "attributes": {
            "allow_overwrite": null,
            "created_on": "2019-03-18T16:37:55.713709Z",
            "data": [
              {
                "name": "extern.test.domain",
                "port": 443,
                "priority": 100,
                "proto": "_tls",
                "service": "_sip",
                "target": "sipdir.online.lync.com",
                "weight": 1
              }
            ],
            "hostname": "_sip._tls.extern.test.domain",
            "id": "a78d9dd5beb0bce415a86a763e0c24c8",
            "metadata": {
              "auto_added": "false",
              "managed_by_apps": "false",
              "managed_by_argo_tunnel": "false",
              "source": "primary"
            },
            "modified_on": "2019-03-18T16:37:55.713709Z",
            "name": "_sip._tls.extern",
            "priority": 100,
            "proxiable": false,
            "proxied": false,
            "timeouts": {
              "create": null,
              "update": null
            },
            "ttl": 86400,
            "type": "SRV",
            "value": "1\t443\tsipdir.online.lync.com",
            "zone_id": "00000000000000000000000000000000"
          },
          "sensitive_attributes": [],
          "private": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
      ]
    }
  ]
}

Actual output

The data-map is missing in the terraform state, and thus, any "plan" or "apply" would result in terraform, trying to update the resource, although there is no difference.
The tfstate after import looks as follows:

{
  "version": 4,
  "terraform_version": "1.2.2",
  "serial": 1,
  "lineage": "51fcb918-7e52-7ea9-45f7-766e218f60ba",
  "outputs": {},
  "resources": [
    {
      "module": "module.test_module",
      "mode": "managed",
      "type": "cloudflare_record",
      "name": "terraform_managed_resource_a78d9dd5beb0bce415a86a763e0c24c8",
      "provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
      "instances": [
        {
          "schema_version": 2,
          "attributes": {
            "allow_overwrite": null,
            "created_on": "2019-03-18T16:37:55.713709Z",
            "data": [],
            "hostname": "_sip._tls.extern.test.domain",
            "id": "a78d9dd5beb0bce415a86a763e0c24c8",
            "metadata": {
              "auto_added": "false",
              "managed_by_apps": "false",
              "managed_by_argo_tunnel": "false",
              "source": "primary"
            },
            "modified_on": "2019-03-18T16:37:55.713709Z",
            "name": "_sip._tls.extern",
            "priority": 100,
            "proxiable": false,
            "proxied": false,
            "timeouts": {
              "create": null,
              "update": null
            },
            "ttl": 86400,
            "type": "SRV",
            "value": "1\t443\tsipdir.online.lync.com",
            "zone_id": "00000000000000000000000000000000"
          },
          "sensitive_attributes": [],
          "private": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
      ]
    }
  ]
}

Attention should be paid to the empty data-array ("data": [],)

Steps to reproduce

  1. Create a DNS-Record of type SRV with some data in it (if you don't have any for your zone/domain)
  2. (optional) let cf-terraforming generate the import-command for you
  3. issue the terraform import command for this record
  4. inspect the tfstate

Additional factoids

Executing "terraform apply" and thus creating an SRV-record will properly create it and the tfstate will have the data-array filled - although with all possible keys, even if they're not explicitly in the config.

References

No response

@Iridias Iridias added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 20, 2022
@jacobbednarz jacobbednarz added triage/accepted Indicates an issue or PR is ready to be actively worked on. service/dns Categorizes issue or PR as related to the DNS service. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 1, 2022
jacobbednarz added a commit that referenced this issue Sep 30, 2022
Fixes the read method to pull from the remote API instead of the local
configuration since on `Import`, the local configuration will be empty.

Fixes #1714
@github-actions github-actions bot added this to the v3.25.0 milestone Sep 30, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

This functionality has been released in v3.25.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. service/dns Categorizes issue or PR as related to the DNS service. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants