hashicorp / terraform-provider-dyn

Terraform Dyn provider. Please note: This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
https://registry.terraform.io
Mozilla Public License 2.0
7 stars 16 forks source link

Dyn Provider can not modify ARecords with multiple values #27

Open lczxpplnzeey opened 6 years ago

lczxpplnzeey commented 6 years ago

Tested and confirmed on:

Terraform v0.11.7 Terraform v0.10.7

Created ARecord test.example.com with the following with terraform apply: 1.1.1.1 1.1.1.2 1.1.1.3

Works no problems, records are created without any issues.

Tried to modify them to with terraform apply again: 2.2.2.1 2.2.2.2 2.2.2.3

but it errors out with the following:

derekargueta commented 6 years ago

@lczxpplnzeey how were you able to get multiple A records working initially? Can you post an anonymized terraform snippet if you don't mind? I've been trying without luck.

And if I run into this issue as well I'll be happy to dive into the code and try to put together a solution.

lczxpplnzeey commented 6 years ago

@derekargueta here's the snippet, with zone, fqdn, IPs changed:

resource "dyn_record" "example-com_1" { name = "" type = "A" value = "1.1.1.1" zone = "example.com" }

resource "dyn_record" "example-com_2" { name = "" type = "A" value = "1.1.1.2" zone = "example.com" }

resource "dyn_record" "example-com_3" { name = "" type = "A" value = "1.1.1.3" zone = "example.com" }

resource "dyn_record" "example-com_4" { name = "" type = "A" value = "1.1.1.4" zone = "example.com" }

sudomateo commented 6 years ago

Confirming that this issue is valid.

How I created the initial records:

variable "example_com_zone" {
  default = "example.com"
}

resource "dyn_record" "www_example_com_01" {
  zone  = "${var.example_com_zone}"
  name  = ""
  value = "127.0.0.1"
  type  = "A"
  ttl   = "3600"
}

resource "dyn_record" "www_example_com_02" {
  zone  = "${var.example_com_zone}"
  name  = ""
  value = "127.0.0.2"
  type  = "A"
  ttl   = "3600"
}

What I changed to modify these records:

variable "example_com_zone" {
  default = "example.com"
}

resource "dyn_record" "www_example_com_01" {
  zone  = "${var.example_com_zone}"
  name  = ""
  value = "127.0.0.11"
  type  = "A"
  ttl   = "3600"
}

resource "dyn_record" "www_example_com_02" {
  zone  = "${var.example_com_zone}"
  name  = ""
  value = "127.0.0.12"
  type  = "A"
  ttl   = "3600"
}

Result:

$ terraform apply
dyn_record.www_example_com_02: Refreshing state... (ID: 365926429)
dyn_record.www_example_com_01: Refreshing state... (ID: 365926426)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ dyn_record.www_example_com_01
      value: "127.0.0.1" => "127.0.0.11"

  ~ dyn_record.www_example_com_02
      value: "127.0.0.2" => "127.0.0.12"

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

dyn_record.www_example_com_02: Modifying... (ID: 365926429)
  value: "127.0.0.2" => "127.0.0.12"
dyn_record.www_example_com_01: Modifying... (ID: 365926426)
  value: "127.0.0.1" => "127.0.0.11"

Error: Error applying plan:

2 error(s) occurred:

* dyn_record.www_example_com_02: 1 error(s) occurred:

* dyn_record.www_example_com_02: Failed to update Dyn record: server responded with 400 Bad Request: {"status": "failure", "data": {}, "job_id": 333824712, "msgs": [{"INFO": "id: Out of date record", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "update: This record is out of date", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}
* dyn_record.www_example_com_01: 1 error(s) occurred:

* dyn_record.www_example_com_01: Failed to update Dyn record: server responded with 400 Bad Request: {"status": "failure", "data": {}, "job_id": 333824723, "msgs": [{"INFO": "id: Out of date record", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "update: This record is out of date", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
lczxpplnzeey commented 6 years ago

@sudomateo Thanks for confirming

@derekargueta Were you able to replicate?

nonai commented 5 years ago

We are also facing a similar issue wherein, the existing A record is not getting deleted.

-- Terraform v0.11.7

mccartney commented 4 years ago

A workaround I have used is to:

instantlinux commented 3 years ago

The title of the issue doesn't cover an even more basic/obvious case. Steps to reproduce:

The workaround noted last month by mccartney is necessary, in addition to manually removing the record at dyn before apply.