Skip to content

Commit 11e1cbc

Browse files
committed
Update the documentation for the resource
1 parent a9d67d5 commit 11e1cbc

File tree

1 file changed

+84
-10
lines changed

1 file changed

+84
-10
lines changed

website/docs/r/nat_gateway.html.markdown

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,102 @@ resource "aws_nat_gateway" "example" {
6161
}
6262
```
6363

64+
### Regional NAT Gateway with auto mode
65+
66+
```terraform
67+
data "aws_availability_zones" "available" {}
68+
69+
resource "aws_vpc" "example" {
70+
cidr_block = "10.0.0.0/16"
71+
}
72+
73+
resource "aws_internet_gateway" "example" {
74+
vpc_id = aws_vpc.example.id
75+
}
76+
77+
resource "aws_nat_gateway" "example" {
78+
vpc_id = aws_vpc.example.id
79+
availability_mode = "regional"
80+
}
81+
```
82+
83+
### Regional NAT Gateway with manual mode
84+
85+
```terraform
86+
data "aws_availability_zones" "available" {}
87+
88+
resource "aws_vpc" "example" {
89+
cidr_block = "10.0.0.0/16"
90+
}
91+
92+
resource "aws_internet_gateway" "example" {
93+
vpc_id = aws_vpc.example.id
94+
}
95+
96+
resource "aws_eip" "example" {
97+
count = 3
98+
domain = "vpc"
99+
}
100+
101+
resource "aws_nat_gateway" "example" {
102+
vpc_id = aws_vpc.example.id
103+
availability_mode = "regional"
104+
105+
availability_zone_address {
106+
allocation_ids = [aws_eip.example[0].id]
107+
availability_zone = data.aws_availability_zones.available.names[0]
108+
}
109+
availability_zone_address {
110+
allocation_ids = [aws_eip.example[1].id, aws_eip.example[2].id]
111+
availability_zone = data.aws_availability_zones.available.names[1]
112+
}
113+
}
114+
```
115+
64116
## Argument Reference
65117

66118
This resource supports the following arguments:
67119

68-
* `allocation_id` - (Optional) The Allocation ID of the Elastic IP address for the NAT Gateway. Required for `connectivity_type` of `public`.
69-
* `connectivity_type` - (Optional) Connectivity type for the NAT Gateway. Valid values are `private` and `public`. Defaults to `public`.
70-
* `private_ip` - (Optional) The private IPv4 address to assign to the NAT Gateway. If you don't provide an address, a private IPv4 address will be automatically assigned.
120+
* `allocation_id` - (Optional, zonal NAT gateways only) The Allocation ID of the Elastic IP address for the NAT Gateway. Required when `connectivity_type` is set to `public` and `availability_mode` is set to `zonal`. When `availability_mode` is set to `regional`, this must not be set; instead, use the `availability_zone_address` block to specify EIPs for each AZ.
121+
* `availability_mode` - (Optional) Specifies whether to create a zonal (single-AZ) or regional (multi-AZ) NAT gateway. Valid values are `zonal` and `regional`. Defaults to `zonal`.
122+
* `availability_zone_address` - (Optional, regional NAT gateways only) Repeatable configuration block for the Elastic IP addresses (EIPs) and availability zones for the regional NAT gateway. When not specified, the regional NAT gateway will automatically expand to new AZs and associate EIPs upon detection of an elastic network interface (auto mode). When specified, auto-expansion is disabled (manual mode). See [`availability_zone_address`](#availability_zone_address) below for details.
123+
124+
* **NOTE:** Once `availability_zone_address` blocks are specified (i.e., when using manual mode), switching to auto mode is not possible without recreating the NAT Gateway. Removing all of these blocks does not trigger resource recreation and results in an error.
125+
* **NOTE:** Moving an `allocation_id` from one availability zone to another within `availability_zone_address` is not supported, because newly added EIPs are associated first, and only then are removed EIPs disassociated. To move it, remove the `allocation_id` from the source availability zone and apply the configuration. Then add it to the destination availability zone and apply again.
126+
* `connectivity_type` - (Optional) Connectivity type for the NAT Gateway. Valid values are `private` and `public`. When `availability_mode` is set to `regional`, this must be set to `public`. Defaults to `public`.
127+
* `private_ip` - (Optional, zonal NAT gateways only) The private IPv4 address to assign to the NAT Gateway. If you don't provide an address, a private IPv4 address will be automatically assigned.
71128
* `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference).
72-
* `subnet_id` - (Required) The Subnet ID of the subnet in which to place the NAT Gateway.
73-
* `secondary_allocation_ids` - (Optional) A list of secondary allocation EIP IDs for this NAT Gateway. To remove all secondary allocations an empty list should be specified.
74-
* `secondary_private_ip_address_count` - (Optional) [Private NAT Gateway only] The number of secondary private IPv4 addresses you want to assign to the NAT Gateway.
75-
* `secondary_private_ip_addresses` - (Optional) A list of secondary private IPv4 addresses to assign to the NAT Gateway. To remove all secondary private addresses an empty list should be specified.
129+
* `subnet_id` - (Optional, zonal NAT gateways only) The Subnet ID of the subnet in which to place the NAT Gateway. Required when `availability_mode` is set to `zonal`. Must not be set when `availability_mode` is set to `regional`.
130+
* `secondary_allocation_ids` - (Optional, zonal NAT gateways only) A list of secondary allocation EIP IDs for this NAT Gateway. To remove all secondary allocations an empty list should be specified.
131+
* `secondary_private_ip_address_count` - (Optional, zonal and private NAT gateways only) The number of secondary private IPv4 addresses you want to assign to the NAT Gateway.
132+
* `secondary_private_ip_addresses` - (Optional, zonal NAT gateways only) A list of secondary private IPv4 addresses to assign to the NAT Gateway. To remove all secondary private addresses an empty list should be specified.
76133
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
134+
* `vpc_id` - (Optional, regional NAT gateways only) VPC ID where this NAT Gateway will be created. Required when `availability_mode` is set to `regional`.
135+
136+
### `availability_zone_address`
137+
138+
* `allocation_ids` - (Required) List of allocation IDs of the Elastic IP addresses (EIPs) to be used for handling outbound NAT traffic in this specific Availability Zone.
139+
* `availability_zone` - (Optional) Availability Zone (e.g. `us-west-2a`) where this specific NAT gateway configuration will be active. If both `availability_zone` and `availability_zone_id` are specified, `availability_zone` will be used.
140+
* `availability_zone_id` - (Optional) Availability Zone ID (e.g. `usw2-az2`) where this specific NAT gateway configuration will be active. If both `availability_zone` and `availability_zone_id` are specified, `availability_zone` will be used.
77141

78142
## Attribute Reference
79143

80144
This resource exports the following attributes in addition to the arguments above:
81145

82-
* `association_id` - The association ID of the Elastic IP address that's associated with the NAT Gateway. Only available when `connectivity_type` is `public`.
146+
* `association_id` - (zonal NAT gateways only) The association ID of the Elastic IP address that's associated with the NAT Gateway. Only available when `connectivity_type` is `public`.
147+
* `auto_provision_zones` - (regional NAT gateways only) Indicates whether AWS automatically manages AZ coverage.
148+
* `auto_scaling_ips` - (regional NAT gateways only) Indicates whether AWS automatically allocates additional Elastic IP addresses (EIPs) in an AZ when the NAT gateway needs more ports due to increased concurrent connections to a single destination from that AZ.
83149
* `id` - The ID of the NAT Gateway.
84-
* `network_interface_id` - The ID of the network interface associated with the NAT Gateway.
85-
* `public_ip` - The Elastic IP address associated with the NAT Gateway.
150+
* `network_interface_id` - (zonal NAT gateways only) The ID of the network interface associated with the NAT Gateway.
151+
* `public_ip` - (zonal NAT gateways only) The Elastic IP address associated with the NAT Gateway.
152+
* `regional_nat_gateway_address` - (regional NAT gateways only) Repeatable blocks for information about the IP addresses and network interface associated with the regional NAT gateway.
153+
* `allocation_id` - Allocation ID of the Elastic IP address.
154+
* `availability_zone` - Availability Zone where this specific NAT gateway configuration is active.
155+
* `availability_zone_id` - Availability Zone ID where this specific NAT gateway configuration is active
156+
* `association_id` - Association ID of the Elastic IP address.
157+
* `network_interface_id` - ID of the network interface.
158+
* `public_ip` - Public IP address.
159+
* `route_table_id` - (regional NAT gateways only) ID of the automatically created route table.
86160
* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).
87161

88162
## Timeouts

0 commit comments

Comments
 (0)