|
| 1 | +**Note**: This public repo contains the documentation for the private GitHub repo <https://github.com/gruntwork-io/module-vpc>. |
| 2 | +We publish the documentation publicly so it turns up in online searches, but to see the source code, you must be a Gruntwork customer. |
| 3 | +If you're already a Gruntwork customer, the original source for this file is at: <https://github.com/gruntwork-io/module-vpc/blob/master/README.md>. |
| 4 | +If you're not a customer, contact us at <[email protected]> or <http://www.gruntwork.io> for info on how to get access! |
| 5 | + |
| 6 | +# VPC Modules |
| 7 | + |
| 8 | +This repo contains modules for creating best-practices Virtual Private Clouds (VPCs) on AWS. |
| 9 | + |
| 10 | +#### Main Modules |
| 11 | + |
| 12 | +The two main modules are: |
| 13 | + |
| 14 | +* [vpc-app](/modules/vpc-app): Launch a VPC meant to house applications. The VPC includes 3 "tiers" of subnets |
| 15 | + (public, private app, private persistence), routing rules, security groups, network ACLs, and NAT gateways. |
| 16 | +* [vpc-mgmt](/modules/vpc-mgmt): Launch a VPC meant to house DevOps and other management services. The VPC includes |
| 17 | + 2 "tiers" of subnets (public, private), routing rules, security groups, network ACLs, and NAT gateways. |
| 18 | + |
| 19 | +#### Supporting Modules |
| 20 | + |
| 21 | +There are also several supporting modules that add extra functionality on top of vpc-app and vpc-mgmt: |
| 22 | + |
| 23 | +* [vpc-peering](/modules/vpc-peering): Creating peering connections between VPCs. Normally, VPCs are completely |
| 24 | + isolated from each other, but sometimes, you want to allow traffic to flow between them, such as allowing DevOps |
| 25 | + tools running in a Mgmt VPC to talk to apps in a Stage or Prod VPC. This module can create peering connections and |
| 26 | + route table entries that make this sort of cross-VPC communication possible. |
| 27 | +* [vpc-app-network-acls](/modules/vpc-app-network-acls): Add a default set of Network ACLs to a VPC created using the |
| 28 | + [vpc-app](/modules/vpc-app) module that control what inbound and outbound network traffic is allowed in each subnet |
| 29 | + of that VPC. |
| 30 | +* [vpc-mgmt-network-acls](/modules/vpc-mgmt-network-acls): Add a default set of Network ACLs to a VPC created using the |
| 31 | + [vpc-mgmt](/modules/vpc-mgmt) module that control what inbound and outbound network traffic is allowed in each subnet |
| 32 | + of that VPC. |
| 33 | +* [network-acl-inbound](/modules/network-acl-inbound): A simple helper for adding inbound rules to a Network ACL, along |
| 34 | + with the corresponding outbound rules for return traffic . |
| 35 | +* [network-acl-outbound](/modules/network-acl-outbound): A simple helper for adding outbound rules to a Network ACL, |
| 36 | + along with the correspoding inbound rules for return traffic. |
| 37 | + |
| 38 | +Click on each module above to see its documentation. Head over to the [examples folder](/examples) for examples. |
| 39 | + |
| 40 | +## What is a module? |
| 41 | + |
| 42 | +At [Gruntwork](http://www.gruntwork.io), we've taken the thousands of hours we spent building infrastructure on AWS and |
| 43 | +condensed all that experience and code into pre-built **packages** or **modules**. Each module is a battle-tested, |
| 44 | +best-practices definition of a piece of infrastructure, such as a VPC, ECS cluster, or an Auto Scaling Group. Modules |
| 45 | +are versioned using [Semantic Versioning](http://semver.org/) to allow Gruntwork clients to keep up to date with the |
| 46 | +latest infrastructure best practices in a systematic way. |
| 47 | + |
| 48 | +## How do you use a module? |
| 49 | + |
| 50 | +Most of our modules contain either: |
| 51 | + |
| 52 | +1. [Terraform](https://www.terraform.io/) code |
| 53 | +1. Scripts & binaries |
| 54 | + |
| 55 | +#### Using a Terraform Module |
| 56 | + |
| 57 | +To use a module in your Terraform templates, create a `module` resource and set its `source` field to the Git URL of |
| 58 | +this repo. You should also set the `ref` parameter so you're fixed to a specific version of this repo, as the `master` |
| 59 | +branch may have backwards incompatible changes (see [module |
| 60 | +sources](https://www.terraform.io/docs/modules/sources.html)). |
| 61 | + |
| 62 | +For example, to use `v1.0.8` of the vpc-app module, you would add the following: |
| 63 | + |
| 64 | +```hcl |
| 65 | +module "ecs_cluster" { |
| 66 | + source = "git::[email protected]:gruntwork-io/module-vpc.git//modules/vpc-app?ref=v1.0.8" |
| 67 | +
|
| 68 | + // set the parameters for the vpc-app module |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +*Note: the double slash (`//`) is intentional and required. It's part of Terraform's Git syntax (see [module |
| 73 | +sources](https://www.terraform.io/docs/modules/sources.html)).* |
| 74 | + |
| 75 | +See the module's documentation and `vars.tf` file for all the parameters you can set. Run `terraform get -update` to |
| 76 | +pull the latest version of this module from this repo before runnin gthe standard `terraform plan` and |
| 77 | +`terraform apply` commands. |
| 78 | + |
| 79 | +#### Using scripts & binaries |
| 80 | + |
| 81 | +You can install the scripts and binaries in the `modules` folder of any repo using the [Gruntwork |
| 82 | +Installer](https://github.com/gruntwork-io/gruntwork-installer). For example, if the scripts you want to install are |
| 83 | +in the `modules/ecs-scripts` folder of the https://github.com/gruntwork-io/module-ecs repo, you could install them |
| 84 | +as follows: |
| 85 | + |
| 86 | +```bash |
| 87 | +gruntwork-install --module-name "ecs-scripts" --repo "https://github.com/gruntwork-io/module-ecs" --tag "0.0.1" |
| 88 | +``` |
| 89 | + |
| 90 | +See the docs for each script & binary for detailed instructions on how to use them. |
| 91 | + |
| 92 | +## What's a VPC? |
| 93 | + |
| 94 | +A [VPC](https://aws.amazon.com/vpc/) or Virtual Private Cloud is a logically isolated section of your AWS cloud. Each |
| 95 | +VPC defines a virtual network within which you run your AWS resources, as well as rules for what can go in and out of |
| 96 | +that network. This includes subnets, route tables that tell those subnets how to route inbound and outbound traffic, |
| 97 | +security groups, firewalls for the subnet (known as "Network ACLs"), and any other network components such as VPN connections. |
| 98 | + |
| 99 | +#### Learn More about VPCs |
| 100 | + |
| 101 | +See the READMEs for the [vpc-app](/modules/vpc-app) and [vpc-mgmt](/modules/vpc-mgmt) modules for detailed info on a VPC, |
| 102 | +along with best practices. |
| 103 | + |
| 104 | +## Developing a module |
| 105 | + |
| 106 | +#### Versioning |
| 107 | + |
| 108 | +We are following the principles of [Semantic Versioning](http://semver.org/). During initial development, the major |
| 109 | +version is to 0 (e.g., `0.x.y`), which indicates the code does not yet have a stable API. Once we hit `1.0.0`, we will |
| 110 | +follow these rules: |
| 111 | + |
| 112 | +1. Increment the patch version for backwards-compatible bug fixes (e.g., `v1.0.8 -> v1.0.9`). |
| 113 | +2. Increment the minor version for new features that are backwards-compatible (e.g., `v1.0.8 -> 1.1.0`). |
| 114 | +3. Increment the major version for any backwards-incompatible changes (e.g. `1.0.8 -> 2.0.0`). |
| 115 | + |
| 116 | +The version is defined using Git tags. Use GitHub to create a release, which will have the effect of adding a git tag. |
| 117 | + |
| 118 | +#### Tests |
| 119 | + |
| 120 | +See the [test](/test) folder for details. |
0 commit comments