Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 083e5d4

Browse files
author
Mike McGirr
committed
Small fixes to get the initial version working
1 parent c9e9014 commit 083e5d4

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

modules/subnets/main.tf

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
*
99
*/
1010

11+
# Turn something like
12+
# var.ipv6_cidr_block = 2600:1f14:929:5700::/56
13+
# into 2600:1f14:929:5700::/64
14+
locals {
15+
# TODO map this over each
16+
# And generate one to match each ipv4 cidr block in the var.cidr_blocks list
17+
# TODO fix. At the moment this only creates one ipv6 cidr block. And that will break if there is more
18+
# than one ipv4 address
19+
ipv6_cidrs = (var.vpc_ipv6_cidr_block == "" ? [] : ["${trimsuffix(var.vpc_ipv6_cidr_block, "56")}64"] )
20+
}
21+
1122
resource "aws_subnet" "main" {
1223
count = length(var.cidr_blocks)
1324
vpc_id = var.vpc_id
@@ -22,6 +33,8 @@ resource "aws_subnet" "main" {
2233
map_public_ip_on_launch = var.public
2334

2435
assign_ipv6_address_on_creation = var.assign_ipv6_address_on_creation
25-
ipv6_cidr_block = var.ipv6_cidr_block
36+
37+
# TODO fix. This will only work with length(var.cidr_blocks) = 1 at the moment
38+
ipv6_cidr_block = local.ipv6_cidrs[count.index]
2639
}
2740

modules/subnets/variables.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ variable "assign_ipv6_address_on_creation" {
3737
default = false
3838
}
3939

40-
variable "ipv6_cidr_block" {
41-
description = "The optional ipv6 cidr block for the subnet"
40+
variable "vpc_ipv6_cidr_block" {
41+
description = "The possible ipv6 cidr block for the vpc"
4242
type = string
4343
default = ""
4444
}
45+
46+
# variable "ipv6_cidr_blocks" {
47+
# description = "The optional ipv6 cidr blocks for the subnet"
48+
# type = list(string)
49+
# default = []
50+
# }

modules/vpc/outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ output "dhcp_options_id" {
1818
# set to true
1919
output "ipv6_cidr_block" {
2020
value = (var.assign_generated_ipv6_cidr_block ? aws_vpc.main.ipv6_cidr_block : "")
21-
description = "Optional IPv6 CIDR block output"
21+
description = "Optional IPv6 CIDR block output for the VPC"
2222
}

0 commit comments

Comments
 (0)