Skip to content

Instantly share code, notes, and snippets.

@RulerOf
Created March 31, 2021 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RulerOf/534b5900d4024256f52e0900ad7db498 to your computer and use it in GitHub Desktop.
Save RulerOf/534b5900d4024256f52e0900ad7db498 to your computer and use it in GitHub Desktop.
DNS SRV Records with Terraform

DNS SRV with Terraform (On AWS Route53)

DNS SRV records are a little cryptic. Even when you create them, it's not particularly obvious what the information in the SRV record actaully means.

When creating the records with Terraform, you can for_each the resource to supply one or more maps that contain better descriptors of the SRV record's constituent components. See the example in the terraform snippet below. Refer here for a longer explanation.

resource "aws_route53_record" "office_365_srv" {
for_each = {
"_sip._tls" = {
port = 443
weight = 100
priority = 1
target = "sipdir.online.lync.com."
}
"_sipfederationtls._tcp" = {
priority = 1
weight = 100
port = 5061
target = "sipfed.online.lync.com."
}
}
zone_id = aws_route53_zone.my_domain.zone_id
name = each.key
type = "SRV"
ttl = "300"
records = ["${each.value.priority} ${each.value.weight} ${each.value.port} ${each.value.target}"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment