From 97205a216c8b67bc2ec0348b05facaaab2ce2caa Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 27 Dec 2022 22:03:46 -0800 Subject: [PATCH] Cleaning up route53 entries --- infra/route53-project-athens-xyz.tf | 49 ++++++++++++++++++----------- infra/route53-shockrah-xyz.tf | 8 ++--- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/infra/route53-project-athens-xyz.tf b/infra/route53-project-athens-xyz.tf index e602387..f831f9d 100644 --- a/infra/route53-project-athens-xyz.tf +++ b/infra/route53-project-athens-xyz.tf @@ -11,26 +11,39 @@ resource "aws_route53_zone" "project-athens" { } -resource "aws_route53_record" "main_ns" { - zone_id = aws_route53_zone.project-athens.id - name = "project-athens.xyz" - type = "NS" - ttl = 172800 - records = [ - "ns-806.awsdns-36.net.", - "ns-1881.awsdns-43.co.uk.", - "ns-1109.awsdns-10.org.", - "ns-11.awsdns-01.com.", +locals { + project-athens-records = [ + { + name = "project-athens.xyz" + type = "NS" + ttl = 172800 + records = [ + "ns-806.awsdns-36.net.", + "ns-1881.awsdns-43.co.uk.", + "ns-1109.awsdns-10.org.", + "ns-11.awsdns-01.com.", + ] + }, + { + name = "project-athens.xyz" + type = "SOA" + ttl = 900 + records = [ + "ns-806.awsdns-36.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400" + ] + } ] } -resource "aws_route53_record" "main_soa" { - zone_id = aws_route53_zone.project-athens.id - name = "project-athens.xyz" - type = "SOA" - ttl = 900 - records = [ - "ns-806.awsdns-36.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400" - ] +resource "aws_route53_record" "project-athens-record" { + for_each = { + for index, record in local.project-athens-records: + index => record + } + zone_id = aws_route53_zone.project-athens.id + name = each.value.name + type = lookup(each.value, "type", "A") + ttl = lookup(each.value, "ttl", 300) + records = each.value.records } diff --git a/infra/route53-shockrah-xyz.tf b/infra/route53-shockrah-xyz.tf index a4db2a1..f78e653 100644 --- a/infra/route53-shockrah-xyz.tf +++ b/infra/route53-shockrah-xyz.tf @@ -34,10 +34,10 @@ locals { ttl = 300 records = [ "v=spf1 include:_mailcust.gandi.net ?all" ] }, - { name = "shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, - { name = "freechat.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, - { name = "resume.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, - { name = "www.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, + { name = "shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, + { name = "freechat.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, + { name = "resume.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, + { name = "www.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] }, ] }