Skip to content

Commit

Permalink
PLT-909 - Adjust the cdn to allow dns ttl and ipv6
Browse files Browse the repository at this point in the history
* allow to adjust the dns ttl and create ipv6 alias
  • Loading branch information
Engerim committed Aug 7, 2024
1 parent 769eeb4 commit 61f3a27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
26 changes: 22 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ data "aws_s3_bucket" "s3_origin" {

module "certificate" {
source = "github.com/terraform-aws-modules/terraform-aws-acm?ref=v5.0.1"
tags = var.tags
tags = merge(var.tags, { Region = "us-east-1" })

domain_name = local.r53_map["single"].hostname
zone_id = local.r53_map["single"].zone_id
Expand All @@ -96,7 +96,7 @@ module "certificate" {
module "certificate-validations" {
source = "github.com/terraform-aws-modules/terraform-aws-acm?ref=v5.0.1"
for_each = local.r53_map
tags = var.tags
tags = merge(var.tags, { Region = "us-east-1" })

domain_name = each.value.hostname
zone_id = each.value.zone_id
Expand All @@ -108,6 +108,8 @@ module "certificate-validations" {
providers = {
aws = aws.us-east-1
}

dns_ttl = var.dns_ttl
}

module "cloudfront" {
Expand Down Expand Up @@ -151,8 +153,9 @@ module "cloudfront" {
}

viewer_certificate = {
acm_certificate_arn = module.certificate.acm_certificate_arn
ssl_support_method = "sni-only"
acm_certificate_arn = module.certificate.acm_certificate_arn
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.2_2021"
}
}

Expand Down Expand Up @@ -212,6 +215,21 @@ resource "aws_route53_record" "this" {
}
}

resource "aws_route53_record" "ipv6" {
count = var.create && var.ipv6 ? 1 : 0

zone_id = var.r53_zone_id
name = var.r53_hostname
type = "AAAA"

alias {
zone_id = module.cloudfront.cloudfront_distribution_hosted_zone_id
name = module.cloudfront.cloudfront_distribution_domain_name

evaluate_target_health = false
}
}

resource "aws_route53_record" "additional_records" {
for_each = var.additional_zones

Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ variable "validation_timeout" {
type = string
default = null
}

variable "dns_ttl" {
description = "dns ttl for the cert validation records"
type = number
default = 60
}

variable "ipv6" {
description = "create also alias records for ipv6"
type = bool
default = false
}

0 comments on commit 61f3a27

Please sign in to comment.