Open lczxpplnzeey opened 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.
@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" }
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.
@sudomateo Thanks for confirming
@derekargueta Were you able to replicate?
We are also facing a similar issue wherein, the existing A record is not getting deleted.
-- Terraform v0.11.7
A workaround I have used is to:
terraform state rm dyn_record.A_
terraform apply
The title of the issue doesn't cover an even more basic/obvious case. Steps to reproduce:
terraform plan
then terraform apply
terraform taint
is insufficient to correct the situation; it will throw errors about record out of date (or already deleted if you try to remove it manually)The workaround noted last month by mccartney is necessary, in addition to manually removing the record at dyn before apply
.
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:
dyn_record.examplecom_2: 1 error(s) occurred:
dyn_record.examplecom_2: Failed to find Dyn record id!
dyn_record.examplecom_3: 1 error(s) occurred:
dyn_record.examplecom_3: Failed to update Dyn record: server responded with 400 Bad Request: {"status": "failure", "data": {}, "job_id": 11111111, "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.examplecom_1: 1 error(s) occurred:
dyn_record.examplecom_1: Failed to update Dyn record: server responded with 400 Bad Request: {"status": "failure", "data": {}, "job_id": 11111111, "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"}]}