Skip to content

Commit 11f9236

Browse files
authored
Added pre-commit hook to autogenerate terraform-docs (terraform-aws-modules#127)
1 parent 55b5991 commit 11f9236

File tree

9 files changed

+229
-45
lines changed

9 files changed

+229
-45
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
sha: v1.4.0
3+
rev: v1.7.0
44
hooks:
55
- id: terraform_fmt
6+
- id: terraform_docs
67
- repo: git://github.com/pre-commit/pre-commit-hooks
7-
sha: v1.2.0
8+
rev: v1.2.3
89
hooks:
910
- id: check-merge-conflict

README.md

Lines changed: 113 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
AWS VPC Terraform module
2-
========================
1+
# AWS VPC Terraform module
32

43
[![Help Contribute to Open Source](https://www.codetriage.com/terraform-aws-modules/terraform-aws-vpc/badges/users.svg)](https://www.codetriage.com/terraform-aws-modules/terraform-aws-vpc)
54

@@ -21,8 +20,7 @@ These types of resources are supported:
2120
* [DHCP Options Set](https://www.terraform.io/docs/providers/aws/r/vpc_dhcp_options.html)
2221
* [Default VPC](https://www.terraform.io/docs/providers/aws/r/default_vpc.html)
2322

24-
Usage
25-
-----
23+
## Usage
2624

2725
```hcl
2826
module "vpc" {
@@ -45,8 +43,7 @@ module "vpc" {
4543
}
4644
```
4745

48-
External NAT Gateway IPs
49-
------------------------
46+
## External NAT Gateway IPs
5047

5148
By default this module will provision new Elastic IPs for the VPC's NAT Gateways.
5249
This means that when creating a new VPC, new IPs are allocated, and when that VPC is destroyed those IPs are released.
@@ -81,8 +78,7 @@ Note that in the example we allocate 3 IPs because we will be provisioning 3 NAT
8178
If, on the other hand, `single_nat_gateway = true`, then `aws_eip.nat` would only need to allocate 1 IP.
8279
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}"]`.
8380

84-
Conditional creation
85-
--------------------
81+
## Conditional creation
8682

8783
Sometimes you need to have a way to create VPC resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_vpc`.
8884

@@ -96,22 +92,122 @@ module "vpc" {
9692
}
9793
```
9894

99-
Terraform version
100-
-----------------
95+
## Terraform version
10196

10297
Terraform version 0.10.3 or newer is required for this module to work.
10398

104-
Examples
105-
--------
99+
## Examples
106100

107101
* [Simple VPC](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/simple-vpc)
108102
* [Complete VPC](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/complete-vpc)
109103
* [Manage Default VPC](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/manage-default-vpc)
110104
* Few tests and edge cases examples: [#46](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-46-no-private-subnets), [#44](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-44-asymmetric-private-subnets), [#108](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-108-route-already-exists)
111105

112-
113-
Tests
114-
-------
106+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
107+
108+
## Inputs
109+
110+
| Name | Description | Type | Default | Required |
111+
|------|-------------|:----:|:-----:|:-----:|
112+
| azs | A list of availability zones in the region | string | `<list>` | no |
113+
| cidr | The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overriden | string | `0.0.0.0/0` | no |
114+
| create_database_subnet_group | Controls if database subnet group should be created | string | `true` | no |
115+
| create_vpc | Controls if VPC should be created (it affects almost all resources) | string | `true` | no |
116+
| database_subnet_tags | Additional tags for the database subnets | string | `<map>` | no |
117+
| database_subnets | A list of database subnets | list | `<list>` | no |
118+
| default_route_table_tags | Additional tags for the default route table | string | `<map>` | no |
119+
| default_vpc_enable_classiclink | Should be true to enable ClassicLink in the Default VPC | string | `false` | no |
120+
| default_vpc_enable_dns_hostnames | Should be true to enable DNS hostnames in the Default VPC | string | `false` | no |
121+
| default_vpc_enable_dns_support | Should be true to enable DNS support in the Default VPC | string | `true` | no |
122+
| default_vpc_name | Name to be used on the Default VPC | string | `` | no |
123+
| default_vpc_tags | Additional tags for the Default VPC | string | `<map>` | no |
124+
| dhcp_options_domain_name | Specifies DNS name for DHCP options set | string | `` | no |
125+
| dhcp_options_domain_name_servers | Specify a list of DNS server addresses for DHCP options set, default to AWS provided | list | `<list>` | no |
126+
| dhcp_options_netbios_name_servers | Specify a list of netbios servers for DHCP options set | list | `<list>` | no |
127+
| dhcp_options_netbios_node_type | Specify netbios node_type for DHCP options set | string | `` | no |
128+
| dhcp_options_ntp_servers | Specify a list of NTP servers for DHCP options set | list | `<list>` | no |
129+
| dhcp_options_tags | Additional tags for the DHCP option set | string | `<map>` | no |
130+
| elasticache_subnet_tags | Additional tags for the elasticache subnets | string | `<map>` | no |
131+
| elasticache_subnets | A list of elasticache subnets | list | `<list>` | no |
132+
| enable_dhcp_options | Should be true if you want to specify a DHCP options set with a custom domain name, DNS servers, NTP servers, netbios servers, and/or netbios server type | string | `false` | no |
133+
| enable_dns_hostnames | Should be true to enable DNS hostnames in the VPC | string | `false` | no |
134+
| enable_dns_support | Should be true to enable DNS support in the VPC | string | `true` | no |
135+
| enable_dynamodb_endpoint | Should be true if you want to provision a DynamoDB endpoint to the VPC | string | `false` | no |
136+
| enable_nat_gateway | Should be true if you want to provision NAT Gateways for each of your private networks | string | `false` | no |
137+
| enable_s3_endpoint | Should be true if you want to provision an S3 endpoint to the VPC | string | `false` | no |
138+
| enable_vpn_gateway | Should be true if you want to create a new VPN Gateway resource and attach it to the VPC | string | `false` | no |
139+
| external_nat_ip_ids | List of EIP IDs to be assigned to the NAT Gateways (used in combination with reuse_nat_ips) | list | `<list>` | no |
140+
| instance_tenancy | A tenancy option for instances launched into the VPC | string | `default` | no |
141+
| manage_default_vpc | Should be true to adopt and manage Default VPC | string | `false` | no |
142+
| map_public_ip_on_launch | Should be false if you do not want to auto-assign public IP on launch | string | `true` | no |
143+
| name | Name to be used on all the resources as identifier | string | `` | no |
144+
| private_route_table_tags | Additional tags for the private route tables | string | `<map>` | no |
145+
| private_subnet_tags | Additional tags for the private subnets | string | `<map>` | no |
146+
| private_subnets | A list of private subnets inside the VPC | string | `<list>` | no |
147+
| propagate_private_route_tables_vgw | Should be true if you want route table propagation | string | `false` | no |
148+
| propagate_public_route_tables_vgw | Should be true if you want route table propagation | string | `false` | no |
149+
| public_route_table_tags | Additional tags for the public route tables | string | `<map>` | no |
150+
| public_subnet_tags | Additional tags for the public subnets | string | `<map>` | no |
151+
| public_subnets | A list of public subnets inside the VPC | string | `<list>` | no |
152+
| redshift_subnet_tags | Additional tags for the redshift subnets | string | `<map>` | no |
153+
| redshift_subnets | A list of redshift subnets | list | `<list>` | no |
154+
| reuse_nat_ips | Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external_nat_ip_ids' variable | string | `false` | no |
155+
| single_nat_gateway | Should be true if you want to provision a single shared NAT Gateway across all of your private networks | string | `false` | no |
156+
| tags | A map of tags to add to all resources | string | `<map>` | no |
157+
| vpc_tags | Additional tags for the VPC | string | `<map>` | no |
158+
| vpn_gateway_id | ID of VPN Gateway to attach to the VPC | string | `` | no |
159+
160+
## Outputs
161+
162+
| Name | Description |
163+
|------|-------------|
164+
| database_subnet_group | ID of database subnet group |
165+
| database_subnets | List of IDs of database subnets |
166+
| database_subnets_cidr_blocks | List of cidr_blocks of database subnets |
167+
| default_network_acl_id | The ID of the default network ACL |
168+
| default_route_table_id | The ID of the default route table |
169+
| default_security_group_id | The ID of the security group created by default on VPC creation |
170+
| default_vpc_cidr_block | The CIDR block of the VPC |
171+
| default_vpc_default_network_acl_id | The ID of the default network ACL |
172+
| default_vpc_default_route_table_id | The ID of the default route table |
173+
| default_vpc_default_security_group_id | The ID of the security group created by default on VPC creation |
174+
| default_vpc_enable_dns_hostnames | Whether or not the VPC has DNS hostname support |
175+
| default_vpc_enable_dns_support | Whether or not the VPC has DNS support |
176+
| default_vpc_id | Default VPC |
177+
| default_vpc_instance_tenancy | Tenancy of instances spin up within VPC |
178+
| default_vpc_main_route_table_id | The ID of the main route table associated with this VPC |
179+
| elasticache_subnet_group | ID of elasticache subnet group |
180+
| elasticache_subnet_group_name | Name of elasticache subnet group |
181+
| elasticache_subnets | List of IDs of elasticache subnets |
182+
| elasticache_subnets_cidr_blocks | List of cidr_blocks of elasticache subnets |
183+
| igw_id | Internet Gateway |
184+
| nat_ids | List of allocation ID of Elastic IPs created for AWS NAT Gateway |
185+
| nat_public_ips | List of public Elastic IPs created for AWS NAT Gateway |
186+
| natgw_ids | List of NAT Gateway IDs |
187+
| private_route_table_ids | List of IDs of private route tables |
188+
| private_subnets | Subnets |
189+
| private_subnets_cidr_blocks | List of cidr_blocks of private subnets |
190+
| public_route_table_ids | Route tables |
191+
| public_subnets | List of IDs of public subnets |
192+
| public_subnets_cidr_blocks | List of cidr_blocks of public subnets |
193+
| redshift_subnet_group | ID of redshift subnet group |
194+
| redshift_subnets | List of IDs of redshift subnets |
195+
| redshift_subnets_cidr_blocks | List of cidr_blocks of redshift subnets |
196+
| vgw_id | VPN Gateway |
197+
| vpc_cidr_block | The CIDR block of the VPC |
198+
| vpc_enable_dns_hostnames | Whether or not the VPC has DNS hostname support |
199+
| vpc_enable_dns_support | Whether or not the VPC has DNS support |
200+
| vpc_endpoint_dynamodb_id | The ID of VPC endpoint for DynamoDB |
201+
| vpc_endpoint_dynamodb_pl_id | The prefix list for the DynamoDB VPC endpoint. |
202+
| vpc_endpoint_s3_id | VPC Endpoints |
203+
| vpc_endpoint_s3_pl_id | The prefix list for the S3 VPC endpoint. |
204+
| vpc_id | VPC |
205+
| vpc_instance_tenancy | Tenancy of instances spin up within VPC |
206+
| vpc_main_route_table_id | The ID of the main route table associated with this VPC |
207+
208+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
209+
210+
## Tests
115211

116212
This module has been packaged with [awspec](https://github.com/k1LoW/awspec) tests through test kitchen. To run them:
117213

@@ -123,13 +219,11 @@ gem install bundler; bundle install
123219
3. Test using `bundle exec kitchen test` from the root of the repo.
124220

125221

126-
Authors
127-
-------
222+
## Authors
128223

129224
Migrated from `terraform-community-modules/tf_aws_vpc`, where it was maintained by [these awesome contributors](https://github.com/terraform-community-modules/tf_aws_vpc/graphs/contributors).
130225
Module managed by [Anton Babenko](https://github.com/antonbabenko).
131226

132-
License
133-
-------
227+
## License
134228

135229
Apache 2 Licensed. See LICENSE for full details.

examples/complete-vpc/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
Complete VPC
2-
============
1+
# Complete VPC
32

43
Configuration in this directory creates set of VPC resources which may be sufficient for staging or production environment (look into [simple-vpc](../simple-vpc) for more simplified setup).
54

65
There are public, private, database, ElastiCache subnets, NAT Gateways created in each availability zone.
76

8-
Usage
9-
=====
7+
## Usage
108

119
To run this example you need to execute:
1210

@@ -17,3 +15,19 @@ $ terraform apply
1715
```
1816

1917
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
21+
## Outputs
22+
23+
| Name | Description |
24+
|------|-------------|
25+
| database_subnets | List of IDs of database subnets |
26+
| elasticache_subnets | List of IDs of elasticache subnets |
27+
| nat_public_ips | NAT gateways |
28+
| private_subnets | Subnets |
29+
| public_subnets | List of IDs of public subnets |
30+
| redshift_subnets | List of IDs of redshift subnets |
31+
| vpc_id | VPC |
32+
33+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
Issue 108 - VPC
2-
==============
1+
# Issue 108 - VPC
32

43
Configuration in this directory creates set of VPC resources to cover issues reported on GitHub:
54

65
* https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/108#issue-308084655
76
* https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/102#issuecomment-374877706
87
* https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/44#issuecomment-378679404
98

10-
Usage
11-
=====
9+
## Usage
1210

1311
To run this example you need to execute:
1412

@@ -19,3 +17,18 @@ $ terraform apply
1917
```
2018

2119
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
20+
21+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
22+
23+
## Outputs
24+
25+
| Name | Description |
26+
|------|-------------|
27+
| database_subnets | List of IDs of database subnets |
28+
| elasticache_subnets | List of IDs of elasticache subnets |
29+
| nat_public_ips | NAT gateways |
30+
| private_subnets | Subnets |
31+
| public_subnets | List of IDs of public subnets |
32+
| vpc_id | VPC |
33+
34+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
Issue 44 - VPC
2-
==============
1+
# Issue 44 - VPC
32

43
Configuration in this directory creates set of VPC resources to cover issues reported on GitHub:
54

65
* https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/44
76

8-
Usage
9-
=====
7+
## Usage
108

119
To run this example you need to execute:
1210

@@ -17,3 +15,18 @@ $ terraform apply
1715
```
1816

1917
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
21+
## Outputs
22+
23+
| Name | Description |
24+
|------|-------------|
25+
| database_subnets | List of IDs of database subnets |
26+
| elasticache_subnets | List of IDs of elasticache subnets |
27+
| nat_public_ips | NAT gateways |
28+
| private_subnets | Subnets |
29+
| public_subnets | List of IDs of public subnets |
30+
| vpc_id | VPC |
31+
32+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
Issue 46 - VPC
2-
==============
1+
# Issue 46 - VPC
32

43
Configuration in this directory creates set of VPC resources to cover issues reported on GitHub:
54

65
* https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/46
76

8-
Usage
9-
=====
7+
## Usage
108

119
To run this example you need to execute:
1210

@@ -17,3 +15,18 @@ $ terraform apply
1715
```
1816

1917
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
21+
## Outputs
22+
23+
| Name | Description |
24+
|------|-------------|
25+
| database_subnets | List of IDs of database subnets |
26+
| elasticache_subnets | List of IDs of elasticache subnets |
27+
| nat_public_ips | NAT gateways |
28+
| private_subnets | Subnets |
29+
| public_subnets | List of IDs of public subnets |
30+
| vpc_id | VPC |
31+
32+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/manage-default-vpc/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
Manage Default VPC
2-
==================
1+
# Manage Default VPC
32

43
Configuration in this directory does not create new VPC resources, but it adopts [Default VPC](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/default-vpc.html) created by AWS to allow management of it using Terraform.
54

65
This is not usual type of resource in Terraform, so use it carefully. More information is [here](https://www.terraform.io/docs/providers/aws/r/default_vpc.html).
76

8-
Usage
9-
=====
7+
## Usage
108

119
To run this example you need to execute:
1210

@@ -17,3 +15,14 @@ $ terraform apply
1715
```
1816

1917
Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
21+
## Outputs
22+
23+
| Name | Description |
24+
|------|-------------|
25+
| default_vpc_cidr_block | The CIDR block of the VPC |
26+
| default_vpc_id | Default VPC |
27+
28+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/simple-vpc/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
Simple VPC
2-
==========
1+
# Simple VPC
32

43
Configuration in this directory creates set of VPC resources which may be sufficient for development environment.
54

65
There is a public and private subnet created per availability zone in addition to single NAT Gateway shared between all 3 availability zones.
76

8-
Usage
9-
=====
7+
## Usage
108

119
To run this example you need to execute:
1210

@@ -17,3 +15,16 @@ $ terraform apply
1715
```
1816

1917
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
21+
## Outputs
22+
23+
| Name | Description |
24+
|------|-------------|
25+
| nat_public_ips | NAT gateways |
26+
| private_subnets | Subnets |
27+
| public_subnets | List of IDs of public subnets |
28+
| vpc_id | VPC |
29+
30+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

0 commit comments

Comments
 (0)