Skip to content

Commit 31e21c3

Browse files
committed
documentation for contributors
1 parent 323d40e commit 31e21c3

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

developer.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Developer Documentation
2+
3+
## Outputs Methodology
4+
5+
This module organizes outputs by creating output collections of grouped entire resources. The benefit of this is that, most likely, attributes users want access to are already present without having to create new `output {}` for each possible attribute. The [potential] downside is that you will have to extract it yourself using HCL logic. See the [outputs.tf](https://github.com/aws-ia/terraform-aws-vpc/blob/b7396f072a95feb367fbc0916f1d2b83a24649df/outputs.tf) for examples.
6+
7+
Our naming convetion attempts to make the output content clear. `route_table_attributes_by_type_by_az` is a nested map of route table resource attributes grouped by their subnet type then by the az. Example:
8+
```terraform
9+
route_table_attributes_by_type_by_az = {
10+
"private" = {
11+
"us-east-1a" = {
12+
"id" = "rtb-0e77040c0598df003"
13+
"route_table_id" = "rtb-0e77040c0598df003"
14+
"tags" = tolist([
15+
{
16+
"key" = "Name"
17+
"value" = "private-us-east-1a"
18+
},
19+
])
20+
"vpc_id" = "vpc-033e054f49409592a"
21+
}
22+
"us-east-1b" = {
23+
...
24+
}
25+
"public" = { ... }
26+
```
27+
28+
## Adding new subnet types
29+
30+
*Note: All subnet types **MUST** accept both `cidrs` and `netmask` arguments.*
31+
32+
1. Updates to variables.tf
33+
34+
1. Add new to `subnets` key variable validation:
35+
36+
```terraform
37+
validation {
38+
error_message = "Only valid key values \"public\", \"private\", or \"transit_gateway\"."
39+
condition = length(setsubtract(keys(var.subnets), [
40+
"public",
41+
"private",
42+
"transit_gateway",
43+
"<new type here>"
44+
])) == 0
45+
}
46+
```
47+
48+
1. Specify keys allowed in new variable type map. Copy an existing one and edit the keys to match what you expect users to input:
49+
50+
```terraform
51+
# All var.subnets.public valid keys
52+
validation {
53+
error_message = "Invalid key in public subnets. Valid options include: \"cidrs\", \"netmask\", \"name_prefix\", \"nat_gateway_configuration\", \"tags\"."
54+
condition = length(setsubtract(keys(try(var.subnets.public, {})), [
55+
"cidrs",
56+
"netmask",
57+
"name_prefix",
58+
"nat_gateway_configuration",
59+
"route_to_transit_gateway",
60+
"tags"
61+
])) == 0
62+
}
63+
```
64+
65+
1. Include in description:
66+
67+
```terraform
68+
**private subnet type options:**
69+
- All shared keys above
70+
- `route_to_nat` = (Optional|bool) <>
71+
- `route_to_transit_gateway` = (Optional|list(string)) <>
72+
```
73+
74+
2. Write configuration code
75+
76+
*Note: each for_each loop must account for if a user does not want to create the particular subnet type. Follow examples from other subnet types in main.tf*
77+
78+
* Create new `aws_subnet`
79+
* Create new `awscc_ec2_route_table`
80+
* Create new `awscc_ec2_subnet_route_table_association`
81+
* Consider and create appropriate `aws_route`
82+
83+
84+
3. Create appropriate outputs
85+
86+
1. `output "<new subnet type>_subnet_attributes_by_az"`
87+
1. add new type to `route_table_attributes_by_type_by_az`

0 commit comments

Comments
 (0)