dnsimple / terraform-provider-dnsimple

Terraform DNSimple provider.
https://www.terraform.io/docs/providers/dnsimple/
Mozilla Public License 2.0
21 stars 20 forks source link

Unable to import existed NS records #131

Closed garry-t closed 11 months ago

garry-t commented 1 year ago

Impossible import resource for NS record. I provided only part of DEBUG output. I'm sure that i provided correct ID for import.

Terraform Version

+ provider registry.terraform.io/dnsimple/dnsimple v1.1.2
+ provider registry.terraform.io/hashicorp/aws v5.6.2
+ provider registry.terraform.io/hashicorp/consul v2.15.1
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hetznercloud/hcloud v1.34.3

Affected Resource(s)

Terraform Configuration Files

resource "dnsimple_zone_record" "aws-ns" {
  for_each = toset(data.aws_route53_zone.lb.name_servers)

  zone_name = var.cdn_domain
  name   = var.lb.subdomain
  value  = each.value
  type   = "NS"
  ttl    = 3600
}

Debug Output

2023-07-10T17:16:03.280+0200 [WARN]  provider.terraform-provider-dnsimple_v1.1.2: removing zone record from state because it is not present in the remote: tf_req_id=744121ad-c985-bb6b-c6a0-ba000b4ecb5b @module=dnsimple tf_mux_provider=*proto6server.Server tf_provider_addr=registry.terraform.io/dnsimple/dnsimple tf_resource_type=dnsimple_zone_record tf_rpc=ReadResource @caller=github.com/terraform-providers/terraform-provider-dnsimple/internal/framework/resources/zone_record_resource.go:224 timestamp=2023-07-10T17:16:03.280+0200
2023-07-10T17:16:03.280+0200 [DEBUG] provider.terraform-provider-dnsimple_v1.1.2: Called provider defined Resource Read: @module=sdk.framework tf_mux_provider=*proto6server.Server tf_provider_addr=registry.terraform.io/dnsimple/dnsimple tf_rpc=ReadResource @caller=github.com/hashicorp/terraform-plugin-framework@v1.2.0/internal/fwserver/server_readresource.go:98 tf_req_id=744121ad-c985-bb6b-c6a0-ba000b4ecb5b tf_resource_type=dnsimple_zone_record timestamp=2023-07-10T17:16:03.280+0200
2023-07-10T17:16:03.280+0200 [WARN]  Provider "registry.terraform.io/dnsimple/dnsimple" produced an unexpected new value for dnsimple_zone_record.aws-ns during refresh.
      - Root resource was present, but now absent
2023-07-10T17:16:03.280+0200 [ERROR] vertex "import dnsimple_zone_record.aws-ns result" error: Cannot import non-existent remote object
2023-07-10T17:16:03.280+0200 [ERROR] vertex "dnsimple_zone_record.aws-ns (import id \"xx-xxx.awsdns-xx.org_123456\")" error: Cannot import non-existent remote object

Panic Output

no

Expected Behavior

NS record imported successfully

Actual Behavior

Error: Cannot import non-existent remote object
│ 
│ While attempting to import an existing object to "dnsimple_zone_record.aws-ns", the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or
│ use "terraform apply" to create a new remote object for this resource.

Steps to Reproduce

terraform import dnsimple_zone_record.aws-ns xx-xxxx.awsdns-xx.org_123456

Important Factoids

Nothing special

References

None

AGS4NO commented 11 months ago

@garry-t Thanks for reaching out. Are you still having issues importing the NS records?

I am able to import NS records that exist for a zone with the following:

resource "dnsimple_zone_record" "ns1" {
  zone_name = var.dnsimple_domain
  name      = ""
  value     = "ns1.dnsimple.com"
  type      = "NS"
  ttl       = 3600
}
$ terraform import dnsimple_zone_record.ns1 terraform-dnsimple-test.com_XXXXXXX

dnsimple_zone_record.ns1: Importing from ID "terraform-dnsimple-test.com_XXXXXXX"...
dnsimple_zone_record.ns1: Import prepared!
  Prepared dnsimple_zone_record for import
dnsimple_zone_record.ns1: Refreshing state...

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.
$ terraform show
# dnsimple_zone_record.ns1:
resource "dnsimple_zone_record" "ns1" {
    id               = XXXXXXX
    priority         = 0
    ttl              = 3600
    type             = "NS"
    value            = "ns1.dnsimple.com"
    value_normalized = "ns1.dnsimple.com"
    zone_id          = "terraform-dnsimple-test.com"
    zone_name        = "terraform-dnsimple-test.com"
}
garry-t commented 11 months ago

yes we still have, I think problem that we have for_each = toset(data.aws_route53_zone.lb.name_servers) unfortunately I didnt find any solution for my configuration. I went through the brutal way just remove DNS entries and recreate from TF. Your case is simple import. If you want you can close ticket.