ClouDNS / terraform-provider-cloudns

A Terraform provider for ClouDNS
Mozilla Public License 2.0
1 stars 0 forks source link

State drift and inability to import #9

Open sempervictus opened 1 week ago

sempervictus commented 1 week ago

Looks like the upstream API changed somehow and the TF provider has "lost track" of a DNS zone which previously existed in the statefile. Trying to import the zone back into the state (tofu import cloudns_dns_zone.name "domain.tld" ) results in:

╷
│ Error: Invalid address to set: []string{"ns"}
│ 
│ 
╵
sempervictus commented 1 week ago

This happens when nameservers are set for a zone, apparently. Quick fix here is:

diff --git i/internal/cloudns/resource_dns_zone.go w/internal/cloudns/resource_dns_zone.go
index 386f343..91a3794 100644
--- i/internal/cloudns/resource_dns_zone.go
+++ w/internal/cloudns/resource_dns_zone.go
@@ -141,11 +141,6 @@ func updateZoneState(d *schema.ResourceData, zone *cloudns.Zone) error {
                return err
        }

-       if len(zone.Ns) > 0 {
-               if err := d.Set("ns", zone.Ns); err != nil {
-                       return err
-               }
-       }

The long-term fix is to update the schema to handle the field

boyanpeychev commented 1 week ago

@sempervictus thanks for the contribution here! Is it possible to provide us the tf file as an example so our team can properly reproduce the problem?

sempervictus commented 1 week ago

Unfortunately no, but you can see in the schema definition that there is no list of strings for "ns" which the current code tries to access (a nonexistent struct member)