From b1eeb1a4c798b954b67965bb5fd041b3142e8bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Thu, 21 Nov 2024 16:32:41 +0200 Subject: [PATCH] wip --- terraform/cloudfront.tf | 4 +--- terraform/locals.tf | 6 +++++- terraform/route53.tf | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/terraform/cloudfront.tf b/terraform/cloudfront.tf index 5bfd17d..fe40f6b 100644 --- a/terraform/cloudfront.tf +++ b/terraform/cloudfront.tf @@ -3,9 +3,7 @@ resource "aws_cloudfront_distribution" "main" { enabled = true is_ipv6_enabled = true http_version = "http2and3" - aliases = [ - var.domain_name - ] + aliases = local.domains origin { domain_name = aws_lb.main.dns_name diff --git a/terraform/locals.tf b/terraform/locals.tf index 1d9a66c..611b0c4 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -4,7 +4,11 @@ locals { repo = "code4romania/rezultatevot", tag = "0.1.1" } - # availability_zone = data.aws_availability_zones.current.names[0] + + domains = [ + var.domain_name, + "www.${var.domain_name}", + ] networking = { cidr_block = "10.0.0.0/16" diff --git a/terraform/route53.tf b/terraform/route53.tf index c208346..98243ae 100644 --- a/terraform/route53.tf +++ b/terraform/route53.tf @@ -1,8 +1,9 @@ # A record resource "aws_route53_record" "ipv4" { + count = length(local.domains) zone_id = data.aws_route53_zone.main.zone_id - name = var.domain_name + name = local.domains[count.index] type = "A" alias { @@ -14,8 +15,10 @@ resource "aws_route53_record" "ipv4" { # AAAA record resource "aws_route53_record" "ipv6" { + count = length(local.domains) + zone_id = data.aws_route53_zone.main.zone_id - name = var.domain_name + name = local.domains[count.index] type = "AAAA" alias {