Posts

Showing posts with the label digital-ocean

Terraform Module with Count Can't Have Duplicate Elements

Image
Clash Royale CLAN TAG #URR8PPP Terraform Module with Count Can't Have Duplicate Elements Tricky one to explain in a title, or even form a question around it, so I'll start with some code (simplified for, err, simplicity): resource "digitalocean_domain" "this_domain" { name = "${var.domain}" ip_address = "${var.main_ip}" } resource "digitalocean_record" "this_a_record" { count = "${length(var.a_records)}" domain = "${var.domain}" type = "A" name = "${element(keys(var.a_records), count.index)}" value = "${lookup(var.a_records, element(keys(var.a_records), count.index))}" } Given the above being part of a module called dns , I can call it like this: dns module "example_com_dns" { source = "./modules/dns" domain = "example.com" main_ip = "1.2.3.4" a_records = { "@" = "5.6.7.8...