go-gandi / terraform-provider-gandi

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

Add nameservers resource #85

Closed nlewo closed 2 years ago

nlewo commented 2 years ago

This resource has to be used to set nameservers on a domain. It takes a list of nameserver. On resource deletion, it enable the LiveDNS nameserver on the domain, which is the domain default state.

To test use it:

resource "gandi_nameservers" "domain" {
  domain = "your-domain.com"
  nameservers = ["ns1.example.foo", "ns2.example.foo"]
}

Once merged, i will push followup PRs to

nlewo commented 2 years ago

@vincentbernat would be nice if you could review/test this PR ;) (at least, I tested it on my domain and it worked fine)

vincentbernat commented 2 years ago

I cannot import an existing resource. It seems that the domain name is both the ID and a required attribute. If that's like for domains, it should just be the ID. Does it make sense? Otherwise, the domain should be set with d.Set() when reading.

nlewo commented 2 years ago

@vincentbernat i'm sorry, i don't understand your issue. Could you provide more details?

I successfully imported a existing nameservers resource with the following resource:

resource "gandi_nameservers" "domain" {
  domain = "domain.com"
  nameservers = ["ns1.example.foo", "ns2.example.foo"]
}

with the following command:

terraform import gandi_nameservers.domain domain.com
vincentbernat commented 2 years ago

OK. I should have tried with Terraform first. With Pulumi, I get:

Diagnostics:
  gandi:domain:Nameservers (enxio.fr):
    error: gandi:domain/nameservers:Nameservers resource 'enxio.fr' has a problem: Missing required argument: The argument "domain" is required, but no definition was found.. Examine values at 'Nameservers.Domain'.
    error: Preview failed: one or more inputs failed to validate

The error is from Terraform SDK, hence I assumed it would be the same with Terraform directly. It works a bit differently than with Terraform as we import by ID. I am unsure if the error is on my side, on Pulumi side or if the provider is doing something that is unexpected.

Nevertheless, I have imported the resource by hand and it works fine. So, ack for me!

nlewo commented 2 years ago

@vincentbernat ok, thanks a lot for your tests.

And let me know if we could improve something in this resource to make it working more easily with Pulumi.

vincentbernat commented 2 years ago

OK, will do. Unfortunately, it seems that Pulumi people are not very interested by stuff outside AWS/GCP/Azure, so it's a bit hard to understand how things should work.