Terraform Code : Adding Muitliple DNS records at once
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adding Multiple DNS records at the same time
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
terraform {
required_providers {
powerdns = {
source = "pan-net/powerdns"
version = "1.5.0"
}
}
}
provider "powerdns" {
api_key = "${var.pdns_api_key}"
server_url = "${var.pdns_server_url}"
insecure_https = true
cache_requests = true
}
Main.tf
# Create a record
resource "powerdns_record" "www" {
# ...
for_each = toset( ["test.dctest.io.","edu.dctest.io.","info.dctest.io."])
name = each.key
zone = "${var.pdns_zone}"
type = "A"
ttl = 300
records = "${var.records}"
}
Variable.tf
variable "pdns_api_key" {
type = string
default = "8x8powerdns"
}
variable "pdns_server_url" {
type = string
default = "http://10.170.20.26:8081"
}
variable "pdns_zone" {
type = string
default = "dctest.io"
}
variable "records" {
type = list
default = [ "10.20.30.1", "10.20.30.2", "10.20.30.3" ]
Comments
Post a Comment