This issue was reported here.
TL;DR:
|
[] |
[""] |
Record removed from PowerDNS server |
โ
|
โ
|
Resource removed from state file? |
โ |
โ
|
Apply finished with success? |
โ
|
โ |
|
[] |
[""] |
Record removed from PowerDNS server |
โ
|
โ
|
Resource removed from state file? |
โ
|
โ
|
Apply finished with success? |
โ |
โ |
โ ๏ธ Because we don't implement Update
, it's important to note that in all cases the record is recreated. So in cases where the record doesn't exist in the state file it's because it failed to create a new one (apply didn't finish with success).
Long Version
Steps to reproduce:
Environment with existing record
Environment:
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 24,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": []
}
$ cat test.tf
resource "powerdns_record" "foobar" {
zone = "sysa.xyz."
name = "something.sysa.xyz."
type = "A"
ttl = 300
records = ["127.0.0.1"]
}
$ terraform apply -auto-approve
powerdns_record.foobar: Creating...
powerdns_record.foobar: Creation complete after 0s [id=something.sysa.xyz.:::A]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
{
"offset": 0,
"length": 19,
"string": "something.sysa.xyz.",
"captures": []
}
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 26,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "powerdns_record",
"name": "foobar",
"provider": "provider.powerdns",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "something.sysa.xyz.:::A",
"name": "something.sysa.xyz.",
"records": [
"127.0.0.1"
],
"set_ptr": null,
"ttl": 300,
"type": "A",
"zone": "sysa.xyz."
},
"private": "bnVsbA=="
}
]
}
]
}
$
1. Changing the value of records
to []
:
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 48,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "powerdns_record",
"name": "foobar",
"provider": "provider.powerdns",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "something.sysa.xyz.:::A",
"name": "something.sysa.xyz.",
"records": [
"127.0.0.1"
],
"set_ptr": null,
"ttl": 300,
"type": "A",
"zone": "sysa.xyz."
},
"private": "bnVsbA=="
}
]
}
]
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
{
"offset": 0,
"length": 19,
"string": "something.sysa.xyz.",
"captures": []
}
$ cat test.tf
resource "powerdns_record" "foobar" {
zone = "sysa.xyz."
name = "something.sysa.xyz."
type = "A"
ttl = 300
records = []
}
$ terraform apply -auto-approve
powerdns_record.foobar: Refreshing state... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destroying... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destruction complete after 0s
powerdns_record.foobar: Creating...
powerdns_record.foobar: Creation complete after 0s [id=something.sysa.xyz.:::A]
Apply complete! Resources: 1 added, 0 changed, 1 destroyed.
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 51,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "powerdns_record",
"name": "foobar",
"provider": "provider.powerdns",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "something.sysa.xyz.:::A",
"name": "something.sysa.xyz.",
"records": null,
"set_ptr": null,
"ttl": 300,
"type": "A",
"zone": "sysa.xyz."
},
"private": "bnVsbA=="
}
]
}
]
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
2. Changing the value of records
to [""]
(same conditions/environment as 1):
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 54,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "powerdns_record",
"name": "foobar",
"provider": "provider.powerdns",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "something.sysa.xyz.:::A",
"name": "something.sysa.xyz.",
"records": [
"127.0.0.1"
],
"set_ptr": null,
"ttl": 300,
"type": "A",
"zone": "sysa.xyz."
},
"private": "bnVsbA=="
}
]
}
]
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
{
"offset": 0,
"length": 19,
"string": "something.sysa.xyz.",
"captures": []
}
$ cat test.tf
resource "powerdns_record" "foobar" {
zone = "sysa.xyz."
name = "something.sysa.xyz."
type = "A"
ttl = 300
records = [""]
}
$ terraform apply -auto-approve
powerdns_record.foobar: Refreshing state... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destroying... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destruction complete after 0s
powerdns_record.foobar: Creating...
Error: Failed to create PowerDNS Record: Error creating record set: something.sysa.xyz.:::A, reason: "Record something.sysa.xyz./A '': Parsing record content (try 'pdnsutil check-zone'): missing field at the end of record content ''"
on test.tf line 1, in resource "powerdns_record" "foobar":
1: resource "powerdns_record" "foobar" {
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 56,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": []
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
$
If the suggestion from here is applied, the behavior is:
A. Using records = []
$ terraform apply -auto-approve
powerdns_record.foobar: Refreshing state... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destroying... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destruction complete after 0s
powerdns_record.foobar: Creating...
Error: Couldn't fetch PowerDNS Record: Unknown record ID format
on test.tf line 1, in resource "powerdns_record" "foobar":
1: resource "powerdns_record" "foobar" {
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 42,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": []
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
$
B. Using records = [""]
:
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 44,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "powerdns_record",
"name": "foobar",
"provider": "provider.powerdns",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "something.sysa.xyz.:::A",
"name": "something.sysa.xyz.",
"records": [
"127.0.0.1"
],
"set_ptr": null,
"ttl": 300,
"type": "A",
"zone": "sysa.xyz."
},
"private": "bnVsbA=="
}
]
}
]
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
{
"offset": 0,
"length": 19,
"string": "something.sysa.xyz.",
"captures": []
}
$ cat test.tf
resource "powerdns_record" "foobar" {
zone = "sysa.xyz."
name = "something.sysa.xyz."
type = "A"
ttl = 300
records = [""]
}
$ terraform apply -auto-approve
powerdns_record.foobar: Refreshing state... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destroying... [id=something.sysa.xyz.:::A]
powerdns_record.foobar: Destruction complete after 0s
powerdns_record.foobar: Creating...
Error: Failed to create PowerDNS Record: Error creating record set: something.sysa.xyz.:::A, reason: "Record something.sysa.xyz./A '': Parsing record content (try 'pdnsutil check-zone'): missing field at the end of record content ''"
on test.tf line 1, in resource "powerdns_record" "foobar":
1: resource "powerdns_record" "foobar" {
$ cat terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.7",
"serial": 46,
"lineage": "5d15eb7d-2f44-4172-ac9d-494cb2534cd2",
"outputs": {},
"resources": []
}
$ curl -X GET -H "X-Api-Key: secret" http://localhost:8081/api/v1/servers/localhost/zones/sysa.xyz. -s | jq '.rrsets[].name | match("something.sysa.xyz.")'
$