Terraform-provider-digitalocean: Changing ip address in digitalocean_domain erases all digitalocean_record s

Created on 4 Nov 2017  路  3Comments  路  Source: digitalocean/terraform-provider-digitalocean

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

$ terraform -v
Terraform v0.10.8

Affected Resource(s)

  • digitalocean_domain
  • digitalocean_record

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "digitalocean_domain" "example" {
  name       = "example.com"
  ip_address = "1.2.3.4"
}

resource "digitalocean_record" "bar" {
  domain = "${digitalocean_domain.example.name}"

  count = "${length(digitalocean_droplet.droplets.*.id)}"

  type   = "A"
  name   = "${element(digitalocean_droplet.droplets.*.name, count.index)}"
  ttl    = 600
  value  = "${element(digitalocean_droplet.droplets.*.ipv4_address_private, count.index)}"
}

Expected Behavior

when i have the domain example.com with all its "A" records set and I change the ip_address of the digitalocean_domain resource, i expect all the digitalocean_record resources to be left or re-created if necessary.

Actual Behavior

when the digitalocean_domain's ip_address is changed, the entire resource is destroyed, which means all the digitalocean_record items are also lost. but the plan does not catch this and the DNS records are not re-created until a subsequent terraform run. This is not good, especially if you're not paying attention and DNS is left incomplete. :/

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ digitalocean_domain.example (new resource required)
      id:         "example.com" => <computed> (forces new resource)
      ip_address: "1.2.3.4" => "4.5.6.7" (forces new resource)
      name:       "example.com" => "example.com"


Plan: 1 to add, 0 to change, 1 to destroy.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
  2. change ip_address
  3. terraform plan
  4. terraform apply
  5. see missing record entries
  6. terraform plan
  7. terrraform apply
  8. see all the records come back

Important Factoids

Nothing special

bug fixed-in-master

Most helpful comment

I'm happy to say that yesterday, we release version 1.0.0 of the DigitalOcean Terraform provider. It should include a fix for this issue.

You can find the full changelog here: https://github.com/terraform-providers/terraform-provider-digitalocean/blob/master/CHANGELOG.md#100-september-27-2018

In order to upgrade an existing project to the latest version, run:

terraform init -upgrade

If you believe that this issue is being closed by mistake or the problem has not been resolved, please let me know or feel free to open a new issue with additional details.

Thanks for your patience!

All 3 comments

can confirm this behavior

We've just released a change to the DO API that should facilitate fixing this. ip_address is now optional. Once Terraform is updated to reflect that, you can create the A record explicitly using digitalocean_record resource rather that automagically through the digitalocean_domain. See: https://developers.digitalocean.com/documentation/changelog/api-v2/create-domains-without-providing-an-ip-address/

I'm happy to say that yesterday, we release version 1.0.0 of the DigitalOcean Terraform provider. It should include a fix for this issue.

You can find the full changelog here: https://github.com/terraform-providers/terraform-provider-digitalocean/blob/master/CHANGELOG.md#100-september-27-2018

In order to upgrade an existing project to the latest version, run:

terraform init -upgrade

If you believe that this issue is being closed by mistake or the problem has not been resolved, please let me know or feel free to open a new issue with additional details.

Thanks for your patience!

Was this page helpful?
0 / 5 - 0 ratings