Skip to content

Commit a2c4bd4

Browse files
authored
Add option for creating AAAA record in r53-alias module (#22)
The site-main and site-redirect modules already support IPv6 (and r53-cname doesn't need to do anything special), so let's add the missing piece of the puzzle.
1 parent f4d2742 commit a2c4bd4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ root domain.
209209
usually pass the `website_cdn_hostname` output variable from the main or redirect site here.
210210
* `cdn_hosted_zone_id`: the Hosted Zone ID of the CloudFront distribution. You usually pass the
211211
`website_cdn_zone_id` output variable from the main or redirect site here.
212-
* `route53_zone_id`: the Route53 Zone ID where the CNAME entry must be created.
212+
* `route53_zone_id`: the Route53 Zone ID where the alias entry must be created.
213+
* `ipv6`: (Optional) Add AAAA record as well as A for the alias. Default value = `false`
213214

214215
## Users
215216

r53-alias/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ resource "aws_route53_record" "cdn-alias" {
1313
}
1414
}
1515

16+
resource "aws_route53_record" "cdn-alias-aaaa" {
17+
count = var.ipv6 ? 1 : 0
18+
19+
zone_id = var.route53_zone_id
20+
name = var.domain
21+
type = "AAAA"
22+
23+
alias {
24+
name = var.target
25+
zone_id = var.cdn_hosted_zone_id
26+
evaluate_target_health = false
27+
}
28+
}

r53-alias/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ variable "route53_zone_id" {
1313
variable "cdn_hosted_zone_id" {
1414
type = string
1515
}
16+
17+
variable "ipv6" {
18+
type = bool
19+
description = "Add AAAA alias record for IPv6 access to CloudFront distribution"
20+
default = false
21+
}

0 commit comments

Comments
 (0)