go-gandi / terraform-provider-gandi

Terraform provider for the Gandi Domain services
Mozilla Public License 2.0
152 stars 45 forks source link

Feature Request - List of Domains in gandi_nameservers #131

Open AshleyJackson opened 2 years ago

AshleyJackson commented 2 years ago

A company with a wide range of domains may want to use a list of domains under the "gandi_nameservers" list to change name servers, instead of each domain having their own "gandi_nameservers" resource.

As we can no longer specify nameservers in gandi_domain, I believe this feature would be very useful.

The current design disallows a list and requires a string

Inappropriate value for attribute "domain": string required.

An Example of a potential working state:

resource "gandi_nameservers" "gandi" {
  domains = [
    "gandiExample1.com",
    "gandiExample2.co.uk"
  ]
  nameservers = [
    "ns-31-a.gandi.net",
    "ns-84-b.gandi.net",
    "ns-200-c.gandi.net",
  ]
}

resource "gandi_nameservers" "cloudflare" {
  domains = [
    "CloudFlareExample3.com",
    "CloudFlareExample4.co.uk"
  ]
  nameservers = [
    "eva.ns.cloudflare.com",
    "pete.ns.cloudflare.com"
  ]
}

Thanks.

ojacobson commented 1 year ago

Would something like this work? Terraform supports mapping resource instances to sets of values out of the box.

resource "gandi_nameservers" "gandi" {
  for_each = toset([
    "gandiExample1.com",
    "gandiExample2.co.uk",
  ])

  domain = each.key
  nameservers = [
    "ns-31-a.gandi.net",
    "ns-84-b.gandi.net",
    "ns-200-c.gandi.net",
  ]
}