terraform-provider-godaddy icon indicating copy to clipboard operation
terraform-provider-godaddy copied to clipboard

terraform destroy removes extra records

Open darkn3rd opened this issue 3 years ago • 3 comments

After managing a single record with Terraform, destroying it later, seems to want to destroy other records that were managed outside of Terraform.

This is extremely problematic, especially for subdomains that use NS records, which is something that the v1 API cannot create, and so have to be created outside of Terraform.

Also, it wants to destroy GoDaddy created records, such of their implementation of domain connect.

STEPS

  1. Create a Single Record
    resource "godaddy_domain_record" "default" {
      domain   = var.domain
    
      record {
        name = var.name
        type = "A"
        data = var.ip_address
        ttl  = 3600
      }
    }
    
  2. terraform apply
    + resource "godaddy_domain_record" "default" {
        + domain = "mycompany.org"
        + id     = (known after apply)
    
        + record {
            + data     = "111.111.111.111"
            + name     = "appvm"
            + port     = 0
            + priority = 0
            + ttl      = 3600
            + type     = "A"
            + weight   = 0
          }
      }
    
  3. terraform destroy

EXPECTED RESULTS

The single A record would be deleted.

ACTUAL RESULTS

Several records are slated to be deleted, ones created by either GoDaddy or in the GUI.

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # module.godaddy_dns_record_address.godaddy_domain_record.default has been changed
  ~ resource "godaddy_domain_record" "default" {
      + addresses = []
        id        = "826728392"
        # (1 unchanged attribute hidden)

      + record {
          + data     = "@"
          + name     = "www"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "CNAME"
          + weight   = 0
        }
      + record {
          + data     = "_domainconnect.gd.domaincontrol.com"
          + name     = "_domainconnect"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "CNAME"
          + weight   = 0
        }
      + record {
          + data     = "ns1-01.azure-dns.com"
          + name     = "dev"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "NS"
          + weight   = 0
        }
      + record {
          + data     = "ns2-01.azure-dns.net"
          + name     = "dev"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "NS"
          + weight   = 0
        }
      + record {
          + data     = "ns3-01.azure-dns.org"
          + name     = "dev"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "NS"
          + weight   = 0
        }
      + record {
          + data     = "ns4-01.azure-dns.info"
          + name     = "dev"
          + port     = 0
          + priority = 0
          + ttl      = 3600
          + type     = "NS"
          + weight   = 0
        }
        # (1 unchanged block hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or
respond to these changes.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # module.godaddy_dns_record_address.godaddy_domain_record.default will be destroyed
  - resource "godaddy_domain_record" "default" {
      - addresses = [] -> null
      - domain    = "mycompany.org" -> null
      - id        = "826728392" -> null

      - record {
          - data     = "111.111.111.111" -> null
          - name     = "appvm" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "A" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "@" -> null
          - name     = "www" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "CNAME" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "_domainconnect.gd.domaincontrol.com" -> null
          - name     = "_domainconnect" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "CNAME" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "ns1-01.azure-dns.com" -> null
          - name     = "dev" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "NS" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "ns2-01.azure-dns.net" -> null
          - name     = "dev" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "NS" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "ns3-01.azure-dns.org" -> null
          - name     = "dev" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "NS" -> null
          - weight   = 0 -> null
        }
      - record {
          - data     = "ns4-01.azure-dns.info" -> null
          - name     = "dev" -> null
          - port     = 0 -> null
          - priority = 0 -> null
          - ttl      = 3600 -> null
          - type     = "NS" -> null
          - weight   = 0 -> null
        }
    }

darkn3rd avatar Jun 14 '21 08:06 darkn3rd

Any word on this?

sps-software avatar Nov 30 '22 03:11 sps-software

Hey @darkn3rd - it sounds like you might want to run terraform import godaddy_domain_record.default var.domain before running terraform apply to make sure that the local Terraform state is in sync.

n3integration avatar Dec 31 '22 16:12 n3integration

It still seems like this is the case, i am not able to even destroy all the records even though to much is deleted it returns with │ Error: [422:INVALID_BODY] Request body doesn't fulfill schema, see details in fields

aaronorosen2 avatar Sep 06 '23 04:09 aaronorosen2