Skip to content

Commit

Permalink
Merge pull request #123 from dxw/add-ipv6-alias-for-service-cloudfront
Browse files Browse the repository at this point in the history
Add an AAAA record for the service which aliases to the ALB or CloudF…
  • Loading branch information
Stretch96 authored Jul 5, 2024
2 parents 33f02cf + d29f7e4 commit 2ee5e7b
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 2ee5e7b

Please sign in to comment.