You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .header.md
+64-29Lines changed: 64 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,45 @@
1
1
# AWS VPC Module
2
2
3
-
This module can be used to deploy a pragmatic VPC with various subnets types in # AZs. Common deployment examples can be found in [examples/](https://github.com/aws-ia/terraform-aws-vpc/tree/main/examples). Subnet CIDRs can be explicitly set via list of string argument `cidrs` or set via a number `netmask` argument.
3
+
This module can be used to deploy a pragmatic VPC with various subnets types in # AZs. Common deployment examples can be found in [examples/](https://github.com/aws-ia/terraform-aws-vpc/tree/main/examples).
4
4
5
5
__Note: For information regarding the 4.0 upgrade see our [upgrade guide](https://github.com/aws-ia/terraform-aws-vpc/blob/main/UPGRADE-GUIDE-4.0.md).__
6
6
7
7
## Usage
8
8
9
-
The example below builds a VPC with public and private subnets in 3 AZs. Each subnet calulates a CIDR based on the `netmask` argument passed. The public subnets build nat gateways in each AZ but optionally can be switched to `single_az`.
9
+
The example below builds a dual-stack VPC with public and private subnets in 3 AZs. Each subnet calculates an IPv4 CIDR based on the `netmask` argument passed, and an IPv6 CIDR with a /64 prefix length. The public subnets build NAT gateways in each AZ but optionally can be switched to `single_az`. An Egress-only Internet gateway is created by using the variable `vpc_egress_only_internet_gateway`.
10
10
11
11
```hcl
12
12
module "vpc" {
13
13
source = "aws-ia/vpc/aws"
14
-
version = ">= 4.0.0"
14
+
version = ">= 4.2.0"
15
15
16
-
name = "multi-az-vpc"
17
-
cidr_block = "10.0.0.0/20"
18
-
az_count = 3
16
+
name = "multi-az-vpc"
17
+
cidr_block = "10.0.0.0/16"
18
+
vpc_assign_generated_ipv6_cidr_block = true
19
+
vpc_egress_only_internet_gateway = true
20
+
az_count = 3
19
21
20
22
subnets = {
23
+
# Dual-stack subnet
21
24
public = {
22
25
name_prefix = "my_public" # omit to prefix with "public"
# omitting name_prefix defaults value to "private"
29
33
# name_prefix = "private_with_egress"
30
34
netmask = 24
31
35
connect_to_public_natgw = true
32
36
}
37
+
# IPv6-only subnet
38
+
private_ipv6 = {
39
+
ipv6_native = true
40
+
assign_ipv6_cidr = true
41
+
connect_to_eigw = true
42
+
}
33
43
}
34
44
35
45
vpc_flow_logs = {
@@ -43,13 +53,7 @@ module "vpc" {
43
53
44
54
There are 3 reserved keys for subnet key names in var.subnets corresponding to types "public", "transit_gateway", and "core_network" [(an AWS Cloud WAN feature)](https://docs.aws.amazon.com/vpc/latest/cloudwan/cloudwan-networks-working-with.html). Other custom subnet key names are valid are and those subnets will be private subnets.
45
55
46
-
```terraform
47
-
transit_gateway_id = <>
48
-
transit_gateway_routes = {
49
-
public = "pl-123"
50
-
vpce = "10.0.0.0/8"
51
-
}
52
-
56
+
```hcl
53
57
subnets = {
54
58
public = {
55
59
name_prefix = "my-public" # omit to prefix with "public"
If using `netmask` to calculate subnets and you wish to either add or remove subnets (ex: adding / removing an AZ), you may have to change from using `netmask` for some subnets and set to explicit instead. Private subnets are always calculated before public.
145
+
If using `netmask`or `assign_ipv6_cidr`to calculate subnets and you wish to either add or remove subnets (ex: adding / removing an AZ), you may have to change from using `netmask` / `assign_ipv6_cidr` for some subnets and set to explicit instead. Private subnets are always calculated before public.
120
146
121
147
When changing to explicit cidrs, subnets are always ordered by AZ. `0` -> a, `1` -> b, etc.
@@ -228,6 +260,7 @@ This happens when the Core Network's VPC attachment requires acceptance, so it's
228
260
subnets = {
229
261
core_network = {
230
262
netmask = 28
263
+
assign_ipv6_cidr = true
231
264
require_acceptance = true
232
265
accept_attachment = true
233
266
}
@@ -240,6 +273,7 @@ subnets = {
240
273
subnets = {
241
274
core_network = {
242
275
netmask = 28
276
+
assign_ipv6_cidr = true
243
277
require_acceptance = true
244
278
accept_attachment = true
245
279
}
@@ -252,6 +286,7 @@ After you apply and the attachment is accepted (outside the module), change the
252
286
subnets = {
253
287
core_network = {
254
288
netmask = 28
289
+
assign_ipv6_cidr = true
255
290
require_acceptance = false
256
291
}
257
292
}
@@ -261,4 +296,4 @@ subnets = {
261
296
262
297
# Contributing
263
298
264
-
Please see our [developer documentation](https://github.com/aws-ia/terraform-aws-vpc/blob/main/contributing.md) for guidance on contributing to this module
299
+
Please see our [developer documentation](https://github.com/aws-ia/terraform-aws-vpc/blob/main/contributing.md) for guidance on contributing to this module.
0 commit comments