Skip to content

Commit

Permalink
Add an AAAA record for the service which aliases to the ALB or CloudF…
Browse files Browse the repository at this point in the history
…ront distribution

So that we can access the service using IPv6 as well as IPv4.
  • Loading branch information
rjw1 authored and Stretch96 committed Jul 5, 2024
1 parent 33f02cf commit d29f7e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ This project creates and manages resources within an AWS account for infrastruct
| [aws_route53_record.service_loadbalancer_record_alb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_record.service_loadbalancer_record_alb_global_accelerator_a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_record.service_record](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_record.service_record_ipv6](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_zone.custom](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
| [aws_route53_zone.infrastructure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
| [aws_route_table.infrastructure_private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource |
Expand Down
16 changes: 16 additions & 0 deletions route53-infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ resource "aws_route53_record" "service_record" {
}
}

resource "aws_route53_record" "service_record_ipv6" {
for_each = local.enable_infrastructure_route53_hosted_zone ? {
for k, v in local.infrastructure_ecs_cluster_services : k => v if v["container_port"] != 0 && v["enable_cloudfront"] == true
} : {}

zone_id = aws_route53_zone.infrastructure[0].zone_id
name = "${each.key}.${local.infrastructure_route53_domain}."
type = "AAAA"

alias {
name = aws_cloudfront_distribution.infrastructure_ecs_cluster_service_cloudfront[each.key].domain_name
zone_id = aws_cloudfront_distribution.infrastructure_ecs_cluster_service_cloudfront[each.key].hosted_zone_id
evaluate_target_health = true
}
}

resource "aws_route53_record" "custom_s3_cloudfront_record" {
for_each = local.enable_infrastructure_route53_hosted_zone ? {
for k, v in local.custom_s3_buckets : k => v if v["cloudfront_dedicated_distribution"] == true
Expand Down

0 comments on commit d29f7e4

Please sign in to comment.