Skip to content

Commit

Permalink
ops(iac/route53): organize subdomains in hosted zones, remove soa rec…
Browse files Browse the repository at this point in the history
…ords from code
  • Loading branch information
datapointchris committed Sep 14, 2024
1 parent 9a3543a commit bc9edfe
Showing 1 changed file with 29 additions and 66 deletions.
95 changes: 29 additions & 66 deletions terraform/route53.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Note: It is not necessary to create the `SOA` records
# as they are automatically created by AWS Route53
# and do not need to be referenced anywhere in the code.

# ---------- Main Site ---------- #
# ---------- ichrisbirch.com / www.ichrisbirch.com ---------- #

resource "aws_route53_zone" "ichrisbirch" {
name = "ichrisbirch.com"
Expand All @@ -10,45 +13,39 @@ resource "aws_route53_zone" "ichrisbirch" {
resource "aws_route53_record" "www_ichrisbirch_a" {
name = "www.ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
# ttl = 300
ttl = 30
ttl = 300
type = "A"
records = [aws_eip.ichrisbirch_elastic_ip.public_ip]
}

# resource "aws_route53_record" "ichrisbirch_soa" {
# name = "ichrisbirch.com"
# zone_id = aws_route53_zone.ichrisbirch.zone_id
# # ttl = 900
# ttl = 30
# type = "SOA"
# allow_overwrite = true
# records = ["ns-721.awsdns-26.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"]
# }

resource "aws_route53_record" "ichrisbirch_ns" {
name = "ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
# ttl = 172800
ttl = 30
name = "ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
ttl = 172800
type = "NS"
allow_overwrite = true
records = aws_route53_zone.ichrisbirch.name_servers
}

resource "aws_route53_record" "api_ichrisbirch_ns_ns" {
name = "api.ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
# ttl = 300
ttl = 30
name = "api.ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
ttl = 300
type = "NS"
allow_overwrite = true
records = aws_route53_zone.api_ichrisbirch.name_servers
depends_on = [aws_route53_zone.api_ichrisbirch]
}

resource "aws_route53_record" "docs_ichrisbirch_cname" {
name = "docs.ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
ttl = 300
type = "CNAME"
records = ["datapointchris.github.io"]
}

# ---------- API Subdomain ---------- #
# ---------- api.ichrisbirch.com ---------- #

resource "aws_route53_zone" "api_ichrisbirch" {
name = "api.ichrisbirch.com"
Expand All @@ -59,36 +56,23 @@ resource "aws_route53_zone" "api_ichrisbirch" {
resource "aws_route53_record" "api_ichrisbirch_a" {
name = "api.ichrisbirch.com"
zone_id = aws_route53_zone.api_ichrisbirch.zone_id
# ttl = 300
ttl = 30
ttl = 300
type = "A"
records = [aws_eip.ichrisbirch_elastic_ip.public_ip]
}

# resource "aws_route53_record" "api_ichrisbirch_soa" {
# name = "api.ichrisbirch.com"
# zone_id = aws_route53_zone.api_ichrisbirch.zone_id
# # ttl = 900
# ttl = 30
# type = "SOA"
# allow_overwrite = true
# records = ["ns-115.awsdns-14.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"]
# }

resource "aws_route53_record" "api_ichrisbirch_ns" {
name = "api.ichrisbirch.com"
zone_id = aws_route53_zone.api_ichrisbirch.zone_id
# ttl = 172800
ttl = 30
name = "api.ichrisbirch.com"
zone_id = aws_route53_zone.api_ichrisbirch.zone_id
ttl = 172800
type = "NS"
allow_overwrite = true
records = aws_route53_zone.api_ichrisbirch.name_servers
}




# ---------- Docs Site ---------- #
# ---------- docs.ichrisbirch.com ---------- #

resource "aws_route53_zone" "docs_ichrisbirch" {
name = "docs.ichrisbirch.com"
Expand All @@ -99,9 +83,8 @@ resource "aws_route53_zone" "docs_ichrisbirch" {
resource "aws_route53_record" "docs_ichrisbirch_a" {
name = "docs.ichrisbirch.com"
zone_id = aws_route53_zone.docs_ichrisbirch.zone_id
# ttl = 300
ttl = 30
type = "A"
ttl = 300
type = "A"
records = [
"185.199.108.153",
"185.199.109.153",
Expand All @@ -110,31 +93,11 @@ resource "aws_route53_record" "docs_ichrisbirch_a" {
]
}

# resource "aws_route53_record" "docs_ichrisbirch_soa" {
# name = "docs.ichrisbirch.com"
# zone_id = aws_route53_zone.docs_ichrisbirch.zone_id
# # ttl = 900
# ttl = 30
# type = "SOA"
# allow_overwrite = true
# records = ["ns-749.awsdns-29.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"]
# }

resource "aws_route53_record" "docs_ichrisbirch_ns" {
name = "docs.ichrisbirch.com"
zone_id = aws_route53_zone.docs_ichrisbirch.zone_id
# ttl = 172800
ttl = 30
name = "docs.ichrisbirch.com"
zone_id = aws_route53_zone.docs_ichrisbirch.zone_id
ttl = 172800
type = "NS"
allow_overwrite = true
records = aws_route53_zone.docs_ichrisbirch.name_servers
}

resource "aws_route53_record" "docs_ichrisbirch_cname" {
name = "docs.ichrisbirch.com"
zone_id = aws_route53_zone.ichrisbirch.zone_id
# ttl = 300
ttl = 30
type = "CNAME"
records = ["datapointchris.github.io"]
}

0 comments on commit bc9edfe

Please sign in to comment.