From 71cf6557673532a5f07abfebc74ee63c763fa110 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 1 Oct 2023 03:11:45 -0700 Subject: [PATCH] Creating DNS entries for temper.tv New ACM certs are still required for the LB to handle requests here properly --- infra/backend.tf | 15 +++++++++++++++ infra/dns.tf | 28 ++++++++++++++++++++++++++++ infra/imports.tf | 0 infra/lb.tf | 6 ++++++ infra/local.tf | 20 ++++++++++++++++++++ infra/variables.tf | 7 +++++++ 6 files changed, 76 insertions(+) create mode 100644 infra/backend.tf create mode 100644 infra/dns.tf create mode 100644 infra/imports.tf create mode 100644 infra/lb.tf create mode 100644 infra/local.tf create mode 100644 infra/variables.tf diff --git a/infra/backend.tf b/infra/backend.tf new file mode 100644 index 0000000..99bffbc --- /dev/null +++ b/infra/backend.tf @@ -0,0 +1,15 @@ +terraform { + required_version = ">= 1.5" + backend "s3" { + bucket = "project-temper-infra" + key = "infra/state/build.tfstate" + region = "us-west-1" + encrypt = true + } + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.0" + } + } +} \ No newline at end of file diff --git a/infra/dns.tf b/infra/dns.tf new file mode 100644 index 0000000..5833161 --- /dev/null +++ b/infra/dns.tf @@ -0,0 +1,28 @@ +resource "aws_route53_zone" "main" { + name = "temper.tv" + comment = "Main zone for temper.tv" +} + +# Points to the Alpha LB in Project Athens +resource "aws_route53_record" "main" { + zone_id = aws_route53_zone.main.id + name = "temper.tv" + type = "A" + + alias { + name = data.aws_lb.alpha.dns_name + zone_id = data.aws_lb.alpha.zone_id + evaluate_target_health = true + } +} + +resource "aws_route53_record" "txt" { + zone_id = aws_route53_zone.main.id + name = "temper.tv" + type = "TXT" + ttl = 300 + records = [ + "v=spf1 include:_mailcust.gandi.net ?all" + ] +} + diff --git a/infra/imports.tf b/infra/imports.tf new file mode 100644 index 0000000..e69de29 diff --git a/infra/lb.tf b/infra/lb.tf new file mode 100644 index 0000000..9ba0fae --- /dev/null +++ b/infra/lb.tf @@ -0,0 +1,6 @@ +# Fetch the Alpha LB from Project Athens + +data "aws_lb" "alpha" { + arn = var.alpha.arn + name = var.alpha.name +} diff --git a/infra/local.tf b/infra/local.tf new file mode 100644 index 0000000..2164a9b --- /dev/null +++ b/infra/local.tf @@ -0,0 +1,20 @@ +locals { + temper-tv-records = [ + # These came with the zone for some reason so there's no need to + # insert them ourselves IG /shrug + # { + # name = "temper.tv" + # type = "NS" + # ttl = 172800 + # records = [ + # "ns-657.awsdns-18.net, + # "ns-1756.awsdns-27.co.uk", + # "ns-1366.awsdns-42.org", + # "ns-288.awsdns-36.com", + # ] + # } + # NOTE SOA record is also taken care of for us :) + # Required for mails to work here + ] +} + diff --git a/infra/variables.tf b/infra/variables.tf new file mode 100644 index 0000000..a4c78d5 --- /dev/null +++ b/infra/variables.tf @@ -0,0 +1,7 @@ +variable "alpha" { + description = "Project Athens Alpha LB" + type = object({ + name = string + arn = string + }) +}