Skip to content

Instantly share code, notes, and snippets.

@jennschiffer
Last active May 3, 2016 19:59
Show Gist options
  • Save jennschiffer/88812bb225bef246fbddc902efecc2d9 to your computer and use it in GitHub Desktop.
Save jennschiffer/88812bb225bef246fbddc902efecc2d9 to your computer and use it in GitHub Desktop.
terraform interpolation or nah
variable "jenn_domains" {
default = "jenn-test.biz,jenn-test.gov,jenn-test.ws"
}
variable "jenn_subdomains" {
default = "cool,sure,whatever"
}
# ROUTE53 CONFIGURATION
resource "aws_route53_zone" "jenn-test-resources" {
count = "${length(split(",", var.jenn_domains))}"
name = "${element(split(",", var.jenn_domains), count.index)}"
lifecycle {
prevent_destroy = true
}
}
# apex records for all jenn-test domains
resource "aws_route53_record" "jenn-apex-records" {
count = "${length(split(",", var.jenn_domains))}"
zone_id = "${element(aws_route53_zone.jenn-test-resources.*.zone_id, count.index)}"
type = "A"
name = "${element(split(",", var.jenn_domains), count.index)}"
ttl = "1"
records = ["127.0.0.1"]
}
# www record for all jenn-test domains
resource "aws_route53_record" "jenn-www-records" {
count = "${length(split(",", var.jenn_domains))}"
zone_id = "${element(aws_route53_zone.jenn-test-resources.*.zone_id, count.index)}"
type = "A"
name = "www"
ttl = "1"
records = ["127.0.0.1"]
}
# subdomain records for *only* jenn-test.biz.
resource "aws_route53_record" "jenn-subdomain-records" {
count = "${length(split(",", var.jenn_subdomains))}"
zone_id = "${aws_route53_zone.jenn-test-resources.0.zone_id}"
type = "A"
name = "${element(split(",", var.jenn_subdomains), count.index)}"
ttl = "1"
records = ["127.0.0.1"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment