go-gandi / terraform-provider-gandi

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

NS subdomain working example in docs #142

Open maxkokocom opened 1 year ago

maxkokocom commented 1 year ago

Hi, I tried adding NS subdomain record, documentation has two ways of doing so, but both did not worked for me, maybe I am missing obv syntax?

Version I am using is: "2.1.0"

1 way I tried adding subdomain NS:

resource "gandi_livedns_record" "ns_dns_record" {
  for_each = local.ns
  zone     = each.value.domain
  name     = each.key
  type     = "NS"
  ttl      = each.value.ttl
  values   = each.value.value
}

locals {
  ns = {
    "aws" : {
      ttl    = 300
      value  = ["ns-1.net", "ns-2.com", "ns-3.co.uk", "ns-4.org"]
      domain = "aws.yyy.xxx."
    }
  }
}

2nd way I tried was:

resource "gandi_nameservers" "ns_dns_record" {
  for_each = local.ns
  domain     = each.value.domain
  name     = each.key
  nameservers   = each.value.value
}

the gandi_livedns_record type NS failed at plan stage with: StatusCode: 404 ; Err: 404: The resource could not be found.

the gandi_nameservers failed at apply stage with:

gandi_nameservers.ns_dns_record["aws"]: Creating...
╷
│ Error: StatusCode: 404 ; Err: 404: The resource could not be found. 
│ 
│   with gandi_nameservers.ns_dns_record["aws"],
│   on main.tf line 37, in resource "gandi_nameservers" "ns_dns_record":
│   37: resource "gandi_nameservers" "ns_dns_record" {

I would appreciate anwser which resource type should I use and maybe a basic example to know why it's failing.

maxkokocom commented 1 year ago

Update, it seems StatusCode: 404 ; Err: 404: The resource could not be found.

Is a result of trying to apply initially. After removing NS records changes it still is raising this error even in the plan stage.

maxkokocom commented 1 year ago

Okey, so I think this is actually some sort of a bug and ticket name should be different, I needed to manually remove this resource: terraform state rm gandi_nameservers.ns_dns_record which on the previous run provider failed to create, but it still added it to the state file so the following plans were complaining that a resource could not be found.

I would still appreciate an example how to do nameservers, but this may be something else entriely.

marcaurele commented 8 months ago

We had the issue which caused us an outage. You should not use the resource gandi_livedns_record for NS records to point to another DNS provider, but use the gandi_nameservers resource. Remove the NS entries from the state file under the gandi_livedns_record.

marcaurele commented 8 months ago

But be aware of #149 that I just opened as their API / provider does not work well.