go-gandi / terraform-provider-gandi

Terraform provider for the Gandi Domain services
Mozilla Public License 2.0
153 stars 46 forks source link

Provider attempts to recreate imported domain due to lack of TTL #57

Closed lbruno closed 2 years ago

lbruno commented 3 years ago

I think this happened because the TTL field is marked as ForceNew, that will then fail. Personally, I think this was caused by the TTL field not being read in this block:

https://github.com/go-gandi/terraform-provider-gandi/blob/master/gandi/resource_livedns_domain.go#L62-L73

I didn't give my API token on Gandi the permission to delete/recreate domains, so I can't say whether this would be a one-off or if it would try to recreate the domain on all plans.

Here's my rationale:

  1. TTL is a required argument for the LiveDNS domain, so I specified some value:
resource "gandi_livedns_domain" "example_net" {
  name = "example.net"
  ttl = 300
}
  1. I ran terraform import gandi_livedns_domain.example_net example.net successfully, and here's a state show:
# gandi_livedns_domain.example_net:
resource "gandi_livedns_domain" "example_net" {
    automatic_snapshots = true
    id                  = "example.net"
    name                = "example.net"

    timeouts {}
}
  1. Note how the ttl value is being "added" when I run terraform plan:
Terraform will perform the following actions:

  # gandi_livedns_domain.example_net must be replaced
-/+ resource "gandi_livedns_domain" "example_net" {
      - automatic_snapshots = true -> null
      ~ id                  = "example.net" -> (known after apply)
        name                = "example.net"
      + ttl                 = 300 # forces replacement

      - timeouts {}
    }

I've started playing around with Terraform 3 days ago, so I'm not familiar enough with TF to be able to speak confidently that this is the source of the bug.

Thanks in advance,

robbyoconnor commented 2 years ago

This hit me as well. @nlewo any advice here as our gandi person?