Split long TXT DNS records
Long TXT record values are a pain to work with, as they need to be quoted in
blocks of 255 characters. In terraform, it is only necessary to insert ""
separators at those boundaries, but that seems to be too cumbersome to do
manually.
So here is a way to just paste the whole record, and let terraform automatically split it up into chunks of max 255 characters:
resource "aws_route53_record" "dkim" {
name = "google._domainkey.example.com"
type = "TXT"
zone_id = aws_route53_zone.example_com.zone_id
ttl = 300
records = [
join("\"\"", regexall(".{1,255}", "v=DKIM1; k=rsa; p=that-super-long-key"))
]
}