INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / RSS / GPG

Import DNS resources from DigitalOcean to Terraform

№ 10401 В разделе Sysadmin от November 19th, 2019,
В подшивках: ,

At first, create digitalocean.tf with auth token if you do not have one.

Carefully read documentation:

  • https://www.terraform.io/docs/providers/do/r/domain.html
  • https://www.terraform.io/docs/providers/do/r/record.html
  • Now prepare domains.tf with resources declaration:

    resource "digitalocean_domain" "k8s_blindage_org" {
      name = "k8s.blindage.org"
    }
    
    resource "digitalocean_record" "k8s_blindage_org_ns1" {
      domain = digitalocean_domain.k8s_blindage_org.name
      type   = "NS"
      name   = "@"
      value  = "ns1.digitalocean.com."
    }
    
    resource "digitalocean_record" "k8s_blindage_org_ns2" {
      domain = digitalocean_domain.k8s_blindage_org.name
      type   = "NS"
      name   = "@"
      value  = "ns2.digitalocean.com."
    }
    
    resource "digitalocean_record" "k8s_blindage_org_ns3" {
      domain = digitalocean_domain.k8s_blindage_org.name
      type   = "NS"
      name   = "@"
      value  = "ns3.digitalocean.com."
    }
    

    Authorize and receive list of records with IDs:

    export DO_TOKEN=fed82d66020b4ccfa67d53d45a519fuck6d3you0c946a9cd196f1062195a7993
    curl -X GET https://api.digitalocean.com/v2/domains/k8s.blindage.org/records -H "Authorization:Bearer ${DO_TOKEN}"

    Now you are ready to import current state with record IDs from previous step:

    terraform import digitalocean_domain.k8s_blindage_org k8s.blindage.org
    terraform import digitalocean_record.k8s_blindage_org_ns1 k8s.blindage.org,80019903
    terraform import digitalocean_record.k8s_blindage_org_ns2 k8s.blindage.org,80019904
    terraform import digitalocean_record.k8s_blindage_org_ns3 k8s.blindage.org,80019905
    

    Нет комментариев »

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    Облачная платформа
    Яндекс.Метрика

    Fortune cookie: The PILLSBURY DOUGHBOY is CRYING for an END to BURT REYNOLDS movies!!