Skip to content

Commit 18f72f8

Browse files
committed
ipv6 parameters for vpc
1 parent 3646569 commit 18f72f8

File tree

5 files changed

+121
-2
lines changed

5 files changed

+121
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ No modules.
404404
| <a name="input_intra_subnets"></a> [intra\_subnets](#input\_intra\_subnets) | A list of intra subnets | `list(string)` | `[]` | no |
405405
| <a name="input_ipv4_ipam_pool_id"></a> [ipv4\_ipam\_pool\_id](#input\_ipv4\_ipam\_pool\_id) | (Optional) The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR. | `string` | `null` | no |
406406
| <a name="input_ipv4_netmask_length"></a> [ipv4\_netmask\_length](#input\_ipv4\_netmask\_length) | (Optional) The netmask length of the IPv4 CIDR you want to allocate to this VPC. Requires specifying a ipv4\_ipam\_pool\_id. | `number` | `null` | no |
407+
| <a name="input_ipv6_cidr"></a> [ipv6\_cidr](#input\_ipv6\_cidr) | (Optional) IPv6 CIDR block to request from an IPAM Pool. Can be set explicitly or derived from IPAM using `ipv6_netmask_length`. | `string` | `null` | no |
408+
| <a name="input_ipv6_ipam_pool_id"></a> [ipv6\_ipam\_pool\_id](#input\_ipv6\_ipam\_pool\_id) | (Optional) IPAM Pool ID for a IPv6 pool. Conflicts with `assign_generated_ipv6_cidr_block`. | `string` | `null` | no |
409+
| <a name="input_ipv6_netmask_length"></a> [ipv6\_netmask\_length](#input\_ipv6\_netmask\_length) | (Optional) Netmask length to request from IPAM Pool. Conflicts with `ipv6_cidr_block`. This can be omitted if IPAM pool as a `allocation_default_netmask_length` set. Valid values: `56`. | `number` | `null` | no |
407410
| <a name="input_manage_default_network_acl"></a> [manage\_default\_network\_acl](#input\_manage\_default\_network\_acl) | Should be true to adopt and manage Default Network ACL | `bool` | `false` | no |
408411
| <a name="input_manage_default_route_table"></a> [manage\_default\_route\_table](#input\_manage\_default\_route\_table) | Should be true to manage default route table | `bool` | `false` | no |
409412
| <a name="input_manage_default_security_group"></a> [manage\_default\_security\_group](#input\_manage\_default\_security\_group) | Should be true to adopt and manage default security group | `bool` | `false` | no |

examples/ipam-vpc/main.tf

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ provider "aws" {
33
}
44

55
locals {
6-
name = "ipam-vpc-example"
6+
name = "ipam-vpc-example"
7+
ipv6_deploy = var.ipv6_pool_cidr != null && var.ipv6_pool_cidr_authorization_message != null && var.ipv6_pool_cidr_authorization_signature != null ? true : false
78
}
89

910
# IPAM Setup
@@ -15,6 +16,8 @@ resource "aws_vpc_ipam" "example" {
1516
}
1617
}
1718

19+
# IPv4 Setup
20+
1821
resource "aws_vpc_ipam_pool" "ipv4_example" {
1922
address_family = "ipv4"
2023
ipam_scope_id = aws_vpc_ipam.example.private_default_scope_id
@@ -27,8 +30,37 @@ resource "aws_vpc_ipam_pool_cidr" "ipv4_example" {
2730
cidr = "172.2.0.0/16"
2831
}
2932

33+
# IPv6 Setup
34+
35+
resource "aws_vpc_ipam_pool" "ipv6_test_public" {
36+
count = local.ipv6_deploy ? 1 : 0
37+
38+
address_family = "ipv6"
39+
ipam_scope_id = aws_vpc_ipam.example.public_default_scope_id
40+
locale = data.aws_region.current.name
41+
description = "public ipv6"
42+
publicly_advertisable = false
43+
aws_service = "ec2"
44+
allocation_default_netmask_length = 56
45+
46+
}
47+
48+
resource "aws_vpc_ipam_pool_cidr" "ipv6_test_public" {
49+
count = local.ipv6_deploy ? 1 : 0
50+
51+
ipam_pool_id = aws_vpc_ipam_pool.ipv6_test_public[0].id
52+
cidr = var.ipv6_pool_cidr
53+
cidr_authorization_context {
54+
message = var.ipv6_pool_cidr_authorization_message
55+
signature = var.ipv6_pool_cidr_authorization_signature
56+
}
57+
}
58+
59+
3060
# Usage Patterns
3161

62+
# IPv4 VPC Examples
63+
3264
module "no_ipam_vpc_example" {
3365
source = "../.."
3466
name = "no-ipam-${local.name}"
@@ -63,3 +95,43 @@ module "ipv4_ipam_default_netmask_vpc" {
6395
aws_vpc_ipam_pool_cidr.ipv4_example
6496
]
6597
}
98+
99+
# IPv6 VPC Examples
100+
101+
module "ipv6_ipam_explicit_cidr_vpc" {
102+
count = local.ipv6_deploy && var.ipv6_ipam_explicit_cidr != null ? 1 : 0
103+
104+
source = "../.."
105+
name = "ipv6-explicit-cidr-${local.name}"
106+
cidr = "172.2.0.32/28"
107+
ipv6_ipam_pool_id = aws_vpc_ipam_pool.ipv6_test_public[0].id
108+
ipv6_cidr = var.ipv6_ipam_explicit_cidr
109+
depends_on = [
110+
aws_vpc_ipam_pool_cidr.ipv6_test_public
111+
]
112+
}
113+
114+
module "ipv6_ipam_explicit_netmask_vpc" {
115+
count = local.ipv6_deploy ? 1 : 0
116+
117+
source = "../.."
118+
name = "ipv6-explicit-netmask-${local.name}"
119+
cidr = "172.2.0.32/28"
120+
ipv6_ipam_pool_id = aws_vpc_ipam_pool.ipv6_test_public[0].id
121+
ipv6_netmask_length = 56
122+
depends_on = [
123+
aws_vpc_ipam_pool_cidr.ipv6_test_public
124+
]
125+
}
126+
127+
module "ipv6_ipam_default_netmask_vpc" {
128+
count = local.ipv6_deploy ? 1 : 0
129+
130+
source = "../.."
131+
name = "ipv6-default-netmask-${local.name}"
132+
cidr = "172.2.0.32/28"
133+
ipv6_ipam_pool_id = aws_vpc_ipam_pool.ipv6_test_public[0].id
134+
depends_on = [
135+
aws_vpc_ipam_pool_cidr.ipv6_test_public
136+
]
137+
}

examples/ipam-vpc/variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variable "ipv6_pool_cidr" {
2+
description = "value"
3+
type = string
4+
default = null
5+
}
6+
7+
variable "ipv6_ipam_explicit_cidr" {
8+
description = "value"
9+
type = string
10+
default = null
11+
}
12+
13+
variable "ipv6_pool_cidr_authorization_signature" {
14+
description = "value"
15+
type = string
16+
default = null
17+
}
18+
19+
variable "ipv6_pool_cidr_authorization_message" {
20+
description = "value"
21+
type = string
22+
default = null
23+
}

main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ resource "aws_vpc" "this" {
3434
enable_dns_support = var.enable_dns_support
3535
enable_classiclink = var.enable_classiclink
3636
enable_classiclink_dns_support = var.enable_classiclink_dns_support
37-
assign_generated_ipv6_cidr_block = var.enable_ipv6
37+
assign_generated_ipv6_cidr_block = var.enable_ipv6 && var.ipv6_ipam_pool_id == "" ? true : null
38+
ipv6_cidr_block = var.ipv6_cidr
39+
ipv6_ipam_pool_id = var.ipv6_ipam_pool_id
40+
ipv6_netmask_length = var.ipv6_netmask_length
3841

3942
tags = merge(
4043
{

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,3 +1186,21 @@ variable "ipv4_netmask_length" {
11861186
type = number
11871187
default = null
11881188
}
1189+
1190+
variable "ipv6_cidr" {
1191+
description = "(Optional) IPv6 CIDR block to request from an IPAM Pool. Can be set explicitly or derived from IPAM using `ipv6_netmask_length`."
1192+
type = string
1193+
default = null
1194+
}
1195+
1196+
variable "ipv6_ipam_pool_id" {
1197+
description = "(Optional) IPAM Pool ID for a IPv6 pool. Conflicts with `assign_generated_ipv6_cidr_block`."
1198+
type = string
1199+
default = null
1200+
}
1201+
1202+
variable "ipv6_netmask_length" {
1203+
description = "(Optional) Netmask length to request from IPAM Pool. Conflicts with `ipv6_cidr_block`. This can be omitted if IPAM pool as a `allocation_default_netmask_length` set. Valid values: `56`."
1204+
type = number
1205+
default = null
1206+
}

0 commit comments

Comments
 (0)