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
@@ -30,15 +30,12 @@ The subnets are dished out across availability zones in a round robin fashion. Y
30
30
The most common use case is to specify the VPC Cidr, the number of public and private subnets.
31
31
32
32
33
-
## Run the Examples | VPC Network
34
-
35
-
You can test-drive this VPC and su
36
-
33
+
---
37
34
38
-
## [Examples and Tests](test-vpc.network)
39
35
40
-
**[This terraform module has runnable example integration tests](test-vpc.network)**. Read the instructions on how to clone the project and run the integration tests.
36
+
## [Run the Example](https://github.com/devops4me/terraform-aws-vpc-network/tree/master/example)
41
37
38
+
You can run the example to see this module create a number of VPCs with varying attributes such as the number of private/public subnets.
42
39
43
40
## Module Inputs
44
41
@@ -48,9 +45,13 @@ You can test-drive this VPC and su
48
45
|**in_num_private_subnets**| Integer | Number of private subnets to create across availability zones | 3 |
49
46
|**in_num_public_subnets**| Integer | Number of public subnets to create across availability zones. If one or more an internet gateway and route to the internet will be created regardless of the value of the in_create_gateway boolean variable. | 3 |
50
47
|**in_create_gateway**| Boolean | If set to true an internet gateway and route will be created even when no public subnets are requested. | false |
51
-
|**in_subnets_max**| Integer | 2 to the power of this is the max number of carvable subnets | 4 (16 subnets) |
48
+
|**[in_subnets_max](https://www.devopswiki.co.uk/vpc/network-cidr)**| Integer | 2 to the power of this is the max number of carvable subnets | 4 (16 subnets) |
52
49
|**in_ecosystem**| String | the class name of the ecosystem being built here | eco-system |
53
50
51
+
52
+
---
53
+
54
+
54
55
## subnets into availability zones | round robin
55
56
56
57
You can create **more or less subnets** than there are availability zones in the VPC's region. You can ask for **6 private subnets** in a **3 availability zone region**. The subnets are distributed into the availability zones like dealing a deck of cards.
@@ -62,51 +63,9 @@ Every permutation of subnets and availability zones is catered for so you can de
62
63
- that **no subnets** (public and/or private) get created
63
64
- nothing - and each availability zone will get one public and one private subnet
64
65
65
-
---
66
-
67
-
## in_subnets_max | variable
68
-
69
-
This variable defines the maximum number of subnets that can be carved out of your VPC (you do not need to use them all). It then combines with the VPC Cidr to define the number of **addresses available in each subnet's** pool.
70
-
71
-
### 2<sup>32 - (in_vpc_cidr + in_subnets_max)</sup> = number of subnet addresses
72
-
73
-
A **vpc_cidr of 21 (eg 10.42.0.0/21)** and **subnets_max of 5** gives a pool of **2<sup>32-(21+5)</sup> = 64 addresses** in each subnet. (Note it is actually 2 less). We can carve out **2<sup>5</sup> = 32 subnets** as in_subnets_max is 5.
74
-
75
-
### Dividing VPC Addresses into Subnet Blocks
76
-
77
-
| vpc cidr | subnets max | number of addresses per subnet | max subnets | vpc addresses total |
Check the below formula holds true for every row in the above table.
85
-
86
-
<pre><code>addresses per subnet * number of subnets = total available VPC addresses</code></pre>
87
66
88
67
---
89
68
90
-
## in_subnets_max | in_vpc_cidr
91
-
92
-
**How many addresses will each subnet contain** and **how many subnets can be carved out of the VPC's IP address pool**? These questions are answered by the vpc_cidr and the subnets_max variable.
93
-
94
-
The VPC Cidr default is 16 giving 65,536 total addresses and the subnets max default is 4 so **16 subnets** can be carved out with each subnet ready to issue 4,096 addresses.
95
-
96
-
Clearly the addresses per subnet multiplied by the number of subnets cannot exceed the available VPC address pool. To keep your powder dry, ensure **in_vpc_cidr plus in_subnets_max does not exceed 31**.
97
-
98
-
## number of subnets constraint
99
-
100
-
It is unlikely **in_num_private_subnets + in_num_public_subnets** will exceed the maximum number of subnets that can be carved out of the VPC. Usually it is a lot less but be prudent and ensure that **in_num_private_subnets + in_num_public_subnets < 2<sup>in_subnets_max</sup>**
101
-
102
-
103
-
## subnet cidr blocks | cidrsubnet function
104
-
105
-
You do not need to specify each subnet's CIDR block because they are calculated by passing the VPC Cidr (in_vpc_cidr), the Subnets Max (in_subnets_max) and the present subnet's index (count.index) into Terraform's **cidrsubnet function**.
106
-
107
-
The behaviour of Terraform's **cidrsubnet function** is involved but slightly outside the scope of this VPC/Subnet module document. Read **[Understanding the Terraform Cidr Subnet Function](http://www.devopswiki.co.uk/wiki/devops/terraform/terraform-cidrsubnet-function)** for a fuller coverage of cidrsubnet's behaviour.
108
-
109
-
---
110
69
111
70
## internet gateway and route
112
71
@@ -115,6 +74,9 @@ This module **senses** whether you wish to **create an internet gateway** (in) a
115
74
If **in_num_public_subnets is greater than zero** it automatically creates an internet gateway and a route along with the public subnets. This behaviour can be switched off by setting **in_ignore_public** to true.
116
75
117
76
77
+
---
78
+
79
+
118
80
## output variables
119
81
120
82
Here are the most popular **output variables** exported from this VPC and subnet creating module.
@@ -126,81 +88,3 @@ Here are the most popular **output variables** exported from this VPC and subnet
126
88
**out_subnet_ids** | List of Strings | [ "subnet-545123498798345", "subnet-83507325124987" ] | list of **all private and public** subnet ids
127
89
**out_private_subnet_ids** | List of Strings | [ "subnet-545123498798345", "subnet-83507325124987" ] | list of **private** subnet ids
128
90
**out_public_subnet_ids** | List of Strings | [ "subnet-945873408204034", "subnet-8940202943031" ] | list of **public** subnet ids
129
-
130
-
## vpc subnets | module tests
131
-
132
-
**[This terraform module has runnable example integration tests](test-vpc.network)**. Read the instructions on how to clone the project and run the unit tests.
133
-
134
-
## vpc subnets | version | v0.1.0002
135
-
136
-
**v0.1.0002** is the current stable version of this Terraform module. To avoid say **testing with one version and going into production with another** you can employ the ref tag as shown below.
Or you can use the version parameter that is more explicit and affords you the opportunity to detail a **[range of versions that are acceptable](https://www.terraform.io/docs/modules/usage.html)** by employing **version constraint syntax**.
The quality and viability of this Terraform module is assured via a continuous integration process.
161
-
162
-
### See 4 Yourself | docker run
163
-
164
-
Why not see 4 yourself by building and running the test. You simply pass in **[[IAM user credentials]](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html)** as **environment variables** to the docker container and Terraform will use these credentials to create the infrastructure.
The default VPC limit is just 5 and this test needs at least 10 so take yourself to the support section and request extension to say 25 - it will be done automatically in less than 5 minutes.
175
-
176
-
## Test Automation | Jenkinsfile
177
-
178
-
179
-
### Contributing
180
-
181
-
Bug reports and pull requests are welcome on GitHub at the https://github.com/devops4me/terraform-aws-vpc-network page. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
182
-
183
-
License
184
-
-------
185
-
186
-
MIT License
187
-
Copyright (c) 2006 - 2014
188
-
189
-
Permission is hereby granted, free of charge, to any person obtaining
190
-
a copy of this software and associated documentation files (the
191
-
'Software'), to deal in the Software without restriction, including
192
-
without limitation the rights to use, copy, modify, merge, publish,
193
-
distribute, sublicense, and/or sell copies of the Software, and to
194
-
permit persons to whom the Software is furnished to do so, subject to
195
-
the following conditions:
196
-
197
-
The above copyright notice and this permission notice shall be
198
-
included in all copies or substantial portions of the Software.
199
-
200
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
201
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
202
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
203
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
204
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
205
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
206
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy file name to clipboardExpand all lines: example/README.md
+30-15Lines changed: 30 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,42 @@
1
1
2
-
# Example | Creating a VPC Network
2
+
# Example | Create an AWS VPC Network
3
3
4
4
This example creates a VPC, subnets and the networking backbone to allow traffic to be routed in and also routed out to service endpoints on the internet. Let's first use docker then do the same thing with terraform installed on your machine.
5
5
6
6
7
7
## Docker | Create VPC Networks
8
8
9
-
With docker, you need not worry about which Terraform version is installed on your machine. All you need is docker and your AWS access credentials.
9
+
With docker, you need not worry about which Terraform version is installed on your machine. All you need are your AWS access credentials.
This **[Jenkinsfile](example/Jenkinsfile)** is used to continuously integrate this module thus guaranteeing correctness and reusability. Ensure you pin the (semantic) version of this module to avoid breaking change failures as it evolves both its functionality and keeps up with Terraform's rapid developmental pace.
15
28
16
-
For even more peace of mind you can clone this project and use your own continuous integration facilities. Send a pull request for any changes that will benefit the Terraform community.
@@ -50,15 +73,7 @@ If you are using an IAM role as the AWS access mechanism then pass it as in_role
50
73
Individuals and small businesses who don't have hundreds of AWS accounts can omit the variable and thanks to dynamic assignment the assume_role block will cease to exist.
51
74
52
75
53
-
docker run \
54
-
--detach \
55
-
--name vm.vpc-network \
56
-
--network host \
57
-
--volume ${PWD}:/home/ubuntu \
58
-
postgres:11.2;
59
-
60
-
61
-
76
+
### The AWS 5 VPC's Limit
62
77
63
-
## Related Modules
78
+
The default VPC limit is just 5 and this test needs at least 10 so take yourself to the support section and request extension to say 25 - it will be done automatically in less than 5 minutes.
0 commit comments