Skip to content

Commit 9f62e8c

Browse files
committed
Add IPv6 support
1 parent 2df6bd6 commit 9f62e8c

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

main.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ module "vpc" {
207207
single_nat_gateway = true
208208
enable_dns_hostnames = !var.enable_ephemeral_storage
209209

210+
enable_ipv6 = var.enable_ipv6
211+
assign_ipv6_address_on_creation = var.enable_ipv6 ? true : null
212+
213+
private_subnet_assign_ipv6_address_on_creation = var.enable_ipv6 ? var.private_subnet_assign_ipv6_address_on_creation : null
214+
215+
public_subnet_ipv6_prefixes = var.public_subnet_ipv6_prefixes
216+
private_subnet_ipv6_prefixes = var.private_subnet_ipv6_prefixes
217+
210218
manage_default_security_group = var.manage_default_security_group
211219
default_security_group_ingress = var.default_security_group_ingress
212220
default_security_group_egress = var.default_security_group_egress
@@ -234,6 +242,8 @@ module "alb" {
234242
prefix = var.alb_log_location_prefix
235243
}
236244

245+
ip_address_type = var.enable_ipv6 ? "dualstack" : "ipv4"
246+
237247
enable_deletion_protection = var.alb_enable_deletion_protection
238248

239249
drop_invalid_header_fields = var.alb_drop_invalid_header_fields
@@ -405,7 +415,7 @@ module "acm" {
405415
}
406416

407417
################################################################################
408-
# Route53 record
418+
# Route53 records
409419
################################################################################
410420
resource "aws_route53_record" "atlantis" {
411421
count = var.create_route53_record ? 1 : 0
@@ -421,6 +431,20 @@ resource "aws_route53_record" "atlantis" {
421431
}
422432
}
423433

434+
resource "aws_route53_record" "atlantis-AAAA" {
435+
count = var.create_route53_record && var.enable_ipv6 ? 1 : 0
436+
437+
zone_id = data.aws_route53_zone.this[0].zone_id
438+
name = var.route53_record_name != null ? var.route53_record_name : var.name
439+
type = "AAAA"
440+
441+
alias {
442+
name = module.alb.lb_dns_name
443+
zone_id = module.alb.lb_zone_id
444+
evaluate_target_health = true
445+
}
446+
}
447+
424448
################################################################################
425449
# EFS
426450
################################################################################

variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,3 +688,27 @@ variable "ephemeral_storage_size" {
688688
error_message = "The minimum supported value is 21 GiB and the maximum supported value is 200 GiB."
689689
}
690690
}
691+
692+
variable "enable_ipv6" {
693+
description = "Enable IPv6 on the VPC and/or ALB"
694+
type = bool
695+
default = false
696+
}
697+
698+
variable "private_subnet_assign_ipv6_address_on_creation" {
699+
description = "Assign IPv6 address on private subnet"
700+
type = bool
701+
default = false
702+
}
703+
704+
variable "public_subnet_ipv6_prefixes" {
705+
description = "Assigns IPv6 private subnet ID based on the Amazon provided /56 prefix"
706+
type = list(number)
707+
default = []
708+
}
709+
710+
variable "private_subnet_ipv6_prefixes" {
711+
description = "Assigns IPv6 public subnet ID based on the Amazon provided /56 prefix"
712+
type = list(number)
713+
default = []
714+
}

0 commit comments

Comments
 (0)