@@ -9,11 +9,11 @@ These types of resources are supported:
9
9
* [ Subnet] ( https://www.terraform.io/docs/providers/aws/r/subnet.html )
10
10
* [ Route] ( https://www.terraform.io/docs/providers/aws/r/route.html )
11
11
* [ Route table] ( https://www.terraform.io/docs/providers/aws/r/route_table.html )
12
- * [ Internet Gateway] ( https://www.terraform.io/docs/providers/aws/r/internet_gateway.html )
12
+ * [ Internet Gateway] ( https://www.terraform.io/docs/providers/aws/r/internet_gateway.html )
13
13
* [ NAT Gateway] ( https://www.terraform.io/docs/providers/aws/r/nat_gateway.html )
14
14
* [ VPN Gateway] ( https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html )
15
15
* [ VPC Endpoint] ( https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html ) (S3 and DynamoDB)
16
- * [ RDS DB Subnet Group] ( https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html )
16
+ * [ RDS DB Subnet Group] ( https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html )
17
17
* [ ElastiCache Subnet Group] ( https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html )
18
18
* [ DHCP Options Set] ( https://www.terraform.io/docs/providers/aws/r/vpc_dhcp_options.html )
19
19
@@ -31,7 +31,7 @@ module "vpc" {
31
31
32
32
name = "my-vpc"
33
33
cidr = "10.0.0.0/16"
34
-
34
+
35
35
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
36
36
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
37
37
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
@@ -46,10 +46,45 @@ module "vpc" {
46
46
}
47
47
```
48
48
49
+ External NAT Gateway IPs
50
+ ------------------------
51
+
52
+ By default this module will provision new Elastic IPs for the VPC's NAT Gateways.
53
+ This means that when creating a new VPC, new IPs are allocated, and when that VPC is destroyed those IPs are released.
54
+ Sometimes it is handy to keep the same IPs even after the VPC is destroyed and re-created.
55
+ To that end, it is possible to assign existing IPs to the NAT Gateways.
56
+ This prevents the destruction of the VPC from releasing those IPs, while making it possible that a re-created VPC uses the same IPs.
57
+
58
+ To achieve this, allocate the IPs outside the VPC module declaration.
59
+ ``` hcl
60
+ resource "aws_eip" "nat" {
61
+ count = 3
62
+
63
+ vpc = true
64
+ }
65
+ ```
66
+
67
+ Then, pass the allocated IPs as a parameter to this module.
68
+ ``` hcl
69
+ module "vpc" {
70
+ source = "terraform-aws-modules/vpc/aws"
71
+
72
+ # The rest of arguments are omitted for brevity
73
+
74
+ enable_nat_gateway = true
75
+ single_nat_gateway = false
76
+ external_nat_ip_ids = ["${resource.aws_eip.nat.*.id}"] # <= IPs specified here as input to the module
77
+ }
78
+ ```
79
+
80
+ Note that in the example we allocate 3 IPs because we will be provisioning 3 NAT Gateways (due to ` single_nat_gateway = false ` and having 3 subnets).
81
+ If, on the other hand, ` single_nat_gateway = true ` , then ` aws_eip.nat ` would only need to allocate 1 IP.
82
+ Passing the IPs into the module is done by setting variable ` external_nat_ip_ids = ["${resource.aws_eip.nat.*.id}"] ` .
83
+
49
84
Terraform version
50
85
-----------------
51
86
52
- Terraform version 1.0.0 or newer is required for this version to work.
87
+ Terraform version 0.10.13 or newer is required for this module to work.
53
88
54
89
Examples
55
90
--------
@@ -66,4 +101,4 @@ Module managed by [Anton Babenko](https://github.com/antonbabenko).
66
101
License
67
102
-------
68
103
69
- Apache 2 Licensed. See LICENSE for full details.
104
+ Apache 2 Licensed. See LICENSE for full details.
0 commit comments