google-cloud-platformgoogle-cloud-dnsgodaddy-api

fix cloud DNS google and Godaddy automatically


I am using terraform to set-up my infrastructure, but use godaddy for my domain hosting. Unfortunately, every time I set-up my Cloud DNS in GCP the nameservers are random between

ns-cloud-{x}1.googledomains.com.  x = a, b, c, d, e

which means there is always a manual step to update these in Godaddy.com. Is there any way this can be automated by fixing the ns-cloud nameservers or automate the nameservers at Godaddy?


Solution

  • I know, I am bit late to the party but you can do this using n3integration like @John Hanely said. Below is my code using which I am able to update my godaddy DNS nameservers.

    # Adding Provider
    
    terraform {
      required_providers {
        godaddy = {
            source = "n3integration/godaddy"
            version = "~> 1.9.1"
        }
      }
    }
    
    # Add your godaddy API KEY and Secret
    
    provider "godaddy" {
      key = jsondecode(file("./godaddy.json")).key
      secret = jsondecode(file("./godaddy.json")).secret
    } 
    
    # Finally 
    
    resource "godaddy_domain_record" "tfs_domain_record" {
      domain = "yourdomain.com"
      addresses = [google_compute_global_address.tf_external_ip.address]
      nameservers = data.google_dns_record_set.tf_record_set.rrdatas
    } 
    

    addresses : Your VM's or Loadbalancer's public IP (static)

    nameservers : Your cloud DNS nameservers