Fred Richards
Posted on October 23, 2019
Recently, I wanted to test the basic powerdns terraform provider, and whether I could write multiple TXT record entries for one name.
Hey, what do you know, it worked. I just had little test messages in there, and decided, maybe it would be neat to put the "DNS Haiku" in a text record. I used the latest Terraform, 0.12.12.
Here's my code. Notice I changed the haiku just a little.
// don't forget to put vars in separate file
// for pdns_api_key & pdns_server_url
provider "powerdns" {
api_key = var.pdns_api_key
server_url = var.pdns_server_url
}
// example of multiple TXT records for name
resource "powerdns_record" "text" {
zone = "geexology.org."
name = "text.geexology.org."
type = "TXT"
ttl = 900
records = ["\"It's not DNS.\"","\"There's no way it's DNS.\"","\"Oh no, DNS.\""]
}
Example tfvars.tf.
// cat tfvars.tf
variable "pdns_api_key" {
description = "current api key"
default = "notrealzlolputyourkeyheresilly"
}
variable "pdns_server_url" {
description = "current api url"
default = "http://127.0.0.1:8087"
}
The reply from the server for the dig query.
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> txt text.geexology.org @172.29.100.102
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22695
;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1680
;; QUESTION SECTION:
;text.geexology.org. IN TXT
;; ANSWER SECTION:
text.geexology.org. 900 IN TXT "It's not DNS."
text.geexology.org. 900 IN TXT "There's no way it's DNS."
text.geexology.org. 900 IN TXT "Oh no, DNS."
;; Query time: 76 msec
;; SERVER: 172.29.100.102#53(172.29.100.102)
;; WHEN: Wed Oct 23 06:19:43 EDT 2019
;; MSG SIZE rcvd: 134
When refreshing state, or performing terraform plan the id looks like this.
powerdns_record.text: Refreshing state... [id=text.geexology.org.:::TXT]
💖 💪 🙅 🚩
Fred Richards
Posted on October 23, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.