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: README.md
+69-2Lines changed: 69 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,33 @@ Note that in the example we allocate 3 IPs because we will be provisioning 3 NAT
67
67
If, on the other hand, `single_nat_gateway = true`, then `aws_eip.nat` would only need to allocate 1 IP.
68
68
Passing the IPs into the module is done by setting two variables `reuse_nat_ips = true` and `external_nat_ip_ids = "${aws_eip.nat.*.id}"`.
69
69
70
+
**For Regional NAT Gateways:**
71
+
When using Regional NAT Gateway with `nat_gateway_connectivity_type.eip_allocation = "manual"`, the module will allocate one EIP per Availability Zone. For example, if you have 3 AZs:
72
+
73
+
```hcl
74
+
resource "aws_eip" "regional_nat" {
75
+
count = 3 # One per AZ
76
+
77
+
vpc = true
78
+
}
79
+
80
+
module "vpc" {
81
+
source = "terraform-aws-modules/vpc/aws"
82
+
83
+
enable_nat_gateway = true
84
+
nat_gateway_connectivity_type = {
85
+
availability_mode = "regional"
86
+
eip_allocation = "manual"
87
+
}
88
+
reuse_nat_ips = false
89
+
}
90
+
```
91
+
92
+
Alternatively, you can use `eip_allocation = "auto"` to let AWS automatically manage EIPs for the Regional NAT Gateway.
93
+
70
94
## NAT Gateway Scenarios
71
95
72
-
This module supports three scenarios for creating NAT gateways. Each will be explained in further detail in the corresponding sections.
96
+
This module supports four scenarios for creating NAT gateways. Each will be explained in further detail in the corresponding sections.
73
97
74
98
- One NAT Gateway per subnet (default behavior)
75
99
-`enable_nat_gateway = true`
@@ -83,9 +107,15 @@ This module supports three scenarios for creating NAT gateways. Each will be exp
By default, the module will determine the number of NAT Gateways to create based on the `max()` of the private subnet lists (`database_subnets`, `elasticache_subnets`, `private_subnets`, and `redshift_subnets`). The module **does not** take into account the number of `intra_subnets`, since the latter are designed to have no Internet access via NAT Gateway. For example, if your configuration looks like the following:
@@ -111,6 +141,43 @@ If `one_nat_gateway_per_az = true` and `single_nat_gateway = false`, then the mo
111
141
- The variable `var.azs`**must** be specified.
112
142
- The number of public subnet CIDR blocks specified in `public_subnets`**must** be greater than or equal to the number of availability zones specified in `var.azs`. This is to ensure that each NAT Gateway has a dedicated public subnet to deploy to.
113
143
144
+
### Regional NAT Gateway
145
+
146
+
Regional NAT Gateway is a highly available NAT solution that automatically scales across multiple Availability Zones within your VPC. It provides a single NAT Gateway that serves all Availability Zones, eliminating the need for multiple zonal NAT Gateways.
147
+
148
+
**Key Features:**
149
+
-**Single NAT Gateway**: One NAT Gateway serves all Availability Zones in your VPC
150
+
-**Automatic High Availability**: Automatically expands and contracts across AZs based on workload distribution
151
+
-**No Public Subnets Required**: Regional NAT Gateways operate without requiring public subnets (though public subnets can still be created for other purposes)
152
+
-**Simplified Management**: Single NAT Gateway ID for consistent route entries across all subnets
153
+
-**Increased Capacity**: Supports up to 32 Elastic IP addresses per AZ (compared to 8 for zonal NAT Gateways)
154
+
155
+
**Configuration:**
156
+
157
+
```hcl
158
+
enable_nat_gateway = true
159
+
nat_gateway_connectivity_type = {
160
+
availability_mode = "regional" # "regional" or "zonal"
161
+
eip_allocation = "auto" # "auto" or "manual"
162
+
}
163
+
```
164
+
165
+
**EIP Allocation Options:**
166
+
-`"auto"`: AWS automatically provisions and manages EIPs for the Regional NAT Gateway
167
+
-`"manual"`: You provide EIPs via `external_nat_ip_ids` (one EIP per AZ). The module will create EIPs based on the number of AZs if `reuse_nat_ips = false`
168
+
169
+
**Important Notes:**
170
+
1.**Expansion Timing**: When deploying workloads in a new AZ, the regional NAT Gateway typically takes 15-20 minutes (up to 60 minutes) to expand to that AZ. During this period, traffic may be temporarily routed through existing AZs.
171
+
2.**Private Connectivity**: Regional NAT Gateways do not support private connectivity. For workloads requiring private connectivity, continue using zonal NAT Gateways.
172
+
3.**Availability**: This feature is available in all commercial AWS Regions, except for AWS GovCloud (US) Regions and China Regions.
173
+
4.**Cost Considerations**: Regional NAT Gateways are charged per hour and per GB processed, similar to zonal NAT Gateways, but you only pay for one NAT Gateway instead of multiple.
174
+
175
+
**Requirements:**
176
+
- Terraform AWS provider >= 6.24.0
177
+
- The variable `var.azs`**must** be specified
178
+
179
+
See the [regional-nat example](examples/regional-nat/) for a complete working example.
180
+
114
181
## "private" versus "intra" subnets
115
182
116
183
By default, if NAT Gateways are enabled, private subnets will be configured with routes for Internet traffic that point at the NAT Gateways configured by use of the above options.
@@ -488,7 +555,7 @@ No modules.
488
555
| <aname="input_map_public_ip_on_launch"></a> [map\_public\_ip\_on\_launch](#input\_map\_public\_ip\_on\_launch)| Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is `false`|`bool`|`false`| no |
489
556
| <aname="input_name"></a> [name](#input\_name)| Name to be used on all the resources as identifier |`string`|`""`| no |
490
557
| <aname="input_nat_eip_tags"></a> [nat\_eip\_tags](#input\_nat\_eip\_tags)| Additional tags for the NAT EIP |`map(string)`|`{}`| no |
491
-
| <aname="input_nat_gateway_connectivity_type"></a> [nat\_gateway\_connectivity\_type](#input\_nat\_gateway\_connectivity\_type)|Connectivity type for the NAT Gateway. Valid values are:<br/>- 'zonal' (default): Traditional AZ-specific NAT gateways that require public subnets<br/>- 'regional': A single NAT Gateway that automatically scales across all AZs (does not require public subnets)<br/><br/>Regional NAT Gateway support requires Terraform AWS provider >= 6.24.0.<br/>When using 'regional' mode, only one NAT Gateway is created for the entire VPC. |`string`|`"zonal"`| no |
558
+
| <aname="input_nat_gateway_connectivity_type"></a> [nat\_gateway\_connectivity\_type](#input\_nat\_gateway\_connectivity\_type)|Configuration block for NAT Gateway connectivity type.<br/>- availability_mode: "zonal" (default) or "regional"<br/> - 'zonal': Traditional AZ-specific NAT gateways that require public subnets<br/>- 'regional': A single NAT Gateway that automatically scales across all AZs (does not require public subnets)<br/>- eip_allocation: "auto" (default) or "manual"<br/> - 'auto': Automatically provision EIPs for the NAT Gateway<br/> - 'manual': Use existing EIPs provided via external_nat_ip_ids<br/><br/>Regional NAT Gateway support requires Terraform AWS provider >= 6.24.0.<br/>When using 'regional' mode, only one NAT Gateway is created for the entire VPC. |`object({ availability_mode = string, eip_allocation = optional(string, "auto") })`|`{ availability_mode = "zonal", eip_allocation = "auto" }`| no |
492
559
| <aname="input_nat_gateway_destination_cidr_block"></a> [nat\_gateway\_destination\_cidr\_block](#input\_nat\_gateway\_destination\_cidr\_block)| Used to pass a custom destination route for private NAT Gateway. If not specified, the default 0.0.0.0/0 is used as a destination route |`string`|`"0.0.0.0/0"`| no |
493
560
| <aname="input_nat_gateway_tags"></a> [nat\_gateway\_tags](#input\_nat\_gateway\_tags)| Additional tags for the NAT gateways |`map(string)`|`{}`| no |
494
561
| <aname="input_one_nat_gateway_per_az"></a> [one\_nat\_gateway\_per\_az](#input\_one\_nat\_gateway\_per\_az)| Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`|`bool`|`false`| no |
description="List of EIPs to be used for `nat_public_ips` output (used in combination with reuse_nat_ips and external_nat_ip_ids)"
1275
+
description="List of EIPs to be used for `nat_public_ips` output (used in combination with reuse_nat_ips and external_nat_ip_ids). For regional NAT gateways, EIPs will be mapped to availability zones in order."
0 commit comments