terrafom: managing dns
I use terraform and CodeCommit to manage our dns changes for each of my current organization's zones. The specific variables are changed for publishing, and I have edited for brevity by showing a single example of each record type. This has significantly simplified our dns management processes. We use an s3 bucket to maintain state, so each of the site techs can make changes without stepping on each other.
/* 180129 - soops@ucla.edu
Deploy myzone.org for Route53
*/
sets the region
provider "aws" {
region = "us-west-2"
}
makes state document an s3 object
terraform {
backend "s3" {
bucket = "myzone.terraform.state"
encrypt = true
key = "global/dns/myzone.org.state"
region = "us-west-2"
}
}
variable "ttl" {
default = "60" # for rapid propagation of changes
}
variable "zone_id" {
default = "myzoneid"
}
resource "aws_route53_record" "apex" {
zone_id = "myzoneid"
name = "myzone.org"
type = "A"
ttl = "${var.ttl}"
records = ["myip"]
}
resource "aws_route53_record" "print" {
zone_id = "${var.zone_id}"
name = "print.myzone.org"
type = "CNAME"
ttl = "${var.ttl}"
records = ["print.otherzone.org"]
}