pretty new to the Terraform world, wanna understand what's the best way to import the dns zone data in bulk to aws_route53 via terraform.
I'm essentially looking to see how to replicate Import Zone File
functionality in route53
via Terraform
for instance, assuming the zone data is a pretty big file generated by dig axfr ...
like this :
; <<>> DiG 9.10.6 <<>> axfr zonetransfer.me @nsztm1.digi.ninja.
;; global options: +cmd
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
zonetransfer.me. 301 IN TXT "google-site-verification=tyP28J7JAUHA9fw2sHXMgcCC0I6XBmmoVi04VlMewxA"
zonetransfer.me. 7200 IN MX 0 ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT1.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT2.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX2.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX3.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX4.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX5.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN A 5.196.105.14
zonetransfer.me. 7200 IN NS nsztm1.digi.ninja.
zonetransfer.me. 7200 IN NS nsztm2.digi.ninja.
_acme-challenge.zonetransfer.me. 301 IN TXT "6Oa05hbUJ9xSsvYy7pApQvwCUSSGgxvrbdizjePEsZI"
... (and much more)
It looks pretty painful/error-prone to create these resources one-by-by in a config file like:
//main.tf
resource "aws_route53_zone" "example" {
name = "zonetransfer.me."
}
resource "aws_route53_record" "A" {
zone_id = aws_route53_zone.example.zone_id
name = aws_route53_zone.example.name
type = "A"
ttl = "7200"
records = ["5.196.105.14"]
}
resource "aws_route53_record" "MX" {
//
}
// all records here
Ideally I'd like to go with something like :
//main.tf
resource "aws_route53_zone" "example" {
name = "zonetransfer.me."
}
resource "aws_route53_record" "all_records" {
file = "<path_to_zone_data_file.txt>"
}
Any suggestions/pointers on how to handle this would be appreciated