From 77ade05768db488e1b4eaa812ea65c017ef1a721 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Fri, 16 Jan 2026 16:38:46 -0500 Subject: [PATCH] Add a redirect for the apex domain to the Django subdomain --- terraform/apex_redirect.tf | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 terraform/apex_redirect.tf diff --git a/terraform/apex_redirect.tf b/terraform/apex_redirect.tf new file mode 100644 index 0000000..9496dfe --- /dev/null +++ b/terraform/apex_redirect.tf @@ -0,0 +1,26 @@ +# Redirect requests for the apex domain to the Django subdomain ("www.") + +resource "aws_s3_bucket" "apex_redirect" { + bucket = aws_route53_zone.this.name +} + +resource "aws_s3_bucket_website_configuration" "apex_redirect" { + bucket = aws_s3_bucket.apex_redirect.id + + redirect_all_requests_to { + host_name = module.django.fqdn + protocol = "https" + } +} + +resource "aws_route53_record" "apex_redirect" { + zone_id = aws_route53_zone.this.zone_id + name = aws_route53_zone.this.name + type = "A" + + alias { + name = aws_s3_bucket_website_configuration.apex_redirect.website_endpoint + zone_id = aws_s3_bucket.apex_redirect.hosted_zone_id + evaluate_target_health = false + } +}