Skip to content

Commit 5cb8cfe

Browse files
authored
Revert "Subnet counts (#54)" (#62)
This reverts commit d7b8237.
1 parent 8f9f137 commit 5cb8cfe

File tree

12 files changed

+41
-222
lines changed

12 files changed

+41
-222
lines changed

README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,23 @@ Available targets:
162162
|------|-------------|:----:|:-----:|:-----:|
163163
| additional_tag_map | Additional tags for appending to each tag map | map | `<map>` | no |
164164
| attributes | Any extra attributes for naming these resources | list | `<list>` | no |
165-
| availability_zones | List of Availability Zones where subnets will be created. When none provided, all availability zones will be used up to the number provided in the public_subnet_count and/or private_subnet_count, and then will be reused if the number of subnets requested is more than the number of availability zones | list | `<list>` | no |
166-
| cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`), or pass in the vpc_id to use the CIDR from the VPC | string | `` | no |
165+
| availability_zones | List of Availability Zones where subnets will be created | list | - | yes |
166+
| cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`) | string | - | yes |
167167
| context | The context output from an external label module to pass to the label modules within this module | map | `<map>` | no |
168168
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
169169
| environment | The environment name if not using stage | string | `` | no |
170170
| igw_id | Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`) | string | - | yes |
171171
| label_order | The naming order of the id output and Name tag | list | `<list>` | no |
172172
| map_public_ip_on_launch | Instances launched into a public subnet should be assigned a public IP address | string | `true` | no |
173-
| max_subnet_count | The maximum number of subnets to deploy. 0 for none, -1 to match the number of az's in the region, or a specific number | string | `-1` | no |
173+
| max_subnet_count | Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every provided availablility zone (in `availability_zones` variable) within the region | string | `0` | no |
174174
| name | Solution name, e.g. 'app' or 'jenkins' | string | `` | no |
175175
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no |
176176
| nat_gateway_enabled | Flag to enable/disable NAT Gateways to allow servers in the private subnets to access the Internet | string | `true` | no |
177177
| nat_instance_enabled | Flag to enable/disable NAT Instances to allow servers in the private subnets to access the Internet | string | `false` | no |
178178
| nat_instance_type | NAT Instance type | string | `t3.micro` | no |
179179
| private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no |
180-
| private_subnet_count | Sets the amount of private subnets to deploy. -1 will deploy a subnet for every availablility zone within the region, 0 will deploy no subnets. The AZ's supplied will be cycled through to create the subnets | string | `-1` | no |
181180
| public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no |
182-
| public_subnet_count | Sets the amount of public subnets to deploy. -1 will deploy a subnet for every availablility zone within the region, 0 will deploy no subnets. The AZ's supplied will be cycled through to create the subnets | string | `-1` | no |
183181
| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no |
184-
| region | The region to pass to the AWS provider nested in this module. | string | - | yes |
185182
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no |
186183
| subnet_type_tag_key | Key for subnet type tag to provide information about the type of subnets, e.g. `cpco.io/subnet/type=private` or `cpco.io/subnet/type=public` | string | `cpco.io/subnet/type` | no |
187184
| subnet_type_tag_value_format | This is using the format interpolation symbols to allow the value of the subnet_type_tag_key to be modified. | string | `%s` | no |
@@ -194,8 +191,6 @@ Available targets:
194191
| Name | Description |
195192
|------|-------------|
196193
| availability_zones | List of Availability Zones where subnets were created |
197-
| availability_zones_private | List of private Availability Zones where subnets were created |
198-
| availability_zones_public | List of public Availability Zones where subnets were created |
199194
| nat_gateway_ids | IDs of the NAT Gateways created |
200195
| nat_instance_ids | IDs of the NAT Instances created |
201196
| private_route_table_ids | IDs of the created private route tables |
@@ -343,27 +338,25 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
343338

344339
### Contributors
345340

346-
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Jamie Nelson][Jamie-BitFlight_avatar]][Jamie-BitFlight_homepage]<br/>[Jamie Nelson][Jamie-BitFlight_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]<br/>[Sergey Vasilyev][s2504s_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] | [![Konstantin B][comeanother_avatar]][comeanother_homepage]<br/>[Konstantin B][comeanother_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]<br/>[Ivan Pinatti][ivan-pinatti_homepage] | [![Oscar Sullivan][osulli_avatar]][osulli_homepage]<br/>[Oscar Sullivan][osulli_homepage] | [![dcowan-vestmark][dcowan-vestmark_avatar]][dcowan-vestmark_homepage]<br/>[dcowan-vestmark][dcowan-vestmark_homepage] |
347-
|---|---|---|---|---|---|---|---|---|
341+
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]<br/>[Sergey Vasilyev][s2504s_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] | [![Konstantin B][comeanother_avatar]][comeanother_homepage]<br/>[Konstantin B][comeanother_homepage] | [![dcowan-vestmark][dcowan-vestmark_avatar]][dcowan-vestmark_homepage]<br/>[dcowan-vestmark][dcowan-vestmark_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]<br/>[Ivan Pinatti][ivan-pinatti_homepage] | [![Oscar Sullivan][osulli_avatar]][osulli_homepage]<br/>[Oscar Sullivan][osulli_homepage] |
342+
|---|---|---|---|---|---|---|---|
348343

349344
[osterman_homepage]: https://github.com/osterman
350345
[osterman_avatar]: https://github.com/osterman.png?size=150
351346
[aknysh_homepage]: https://github.com/aknysh
352347
[aknysh_avatar]: https://github.com/aknysh.png?size=150
353-
[Jamie-BitFlight_homepage]: https://github.com/Jamie-BitFlight
354-
[Jamie-BitFlight_avatar]: https://github.com/Jamie-BitFlight.png?size=150
355348
[s2504s_homepage]: https://github.com/s2504s
356349
[s2504s_avatar]: https://github.com/s2504s.png?size=150
357350
[SweetOps_homepage]: https://github.com/SweetOps
358351
[SweetOps_avatar]: https://github.com/SweetOps.png?size=150
359352
[comeanother_homepage]: https://github.com/comeanother
360353
[comeanother_avatar]: https://github.com/comeanother.png?size=150
354+
[dcowan-vestmark_homepage]: https://github.com/dcowan-vestmark
355+
[dcowan-vestmark_avatar]: https://github.com/dcowan-vestmark.png?size=150
361356
[ivan-pinatti_homepage]: https://github.com/ivan-pinatti
362357
[ivan-pinatti_avatar]: https://github.com/ivan-pinatti.png?size=150
363358
[osulli_homepage]: https://github.com/osulli
364359
[osulli_avatar]: https://github.com/osulli.png?size=150
365-
[dcowan-vestmark_homepage]: https://github.com/dcowan-vestmark
366-
[dcowan-vestmark_avatar]: https://github.com/dcowan-vestmark.png?size=150
367360

368361

369362

README.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,16 @@ contributors:
9898
github: "osterman"
9999
- name: "Andriy Knysh"
100100
github: "aknysh"
101-
- name: "Jamie Nelson"
102-
github: "Jamie-BitFlight"
103101
- name: "Sergey Vasilyev"
104102
github: "s2504s"
105103
- name: "Vladimir"
106104
github: "SweetOps"
107105
- name: "Konstantin B"
108106
github: "comeanother"
107+
- name: "dcowan-vestmark"
108+
github: "dcowan-vestmark"
109109
- name: "Ivan Pinatti"
110110
github: "ivan-pinatti"
111111
- name: "Oscar Sullivan"
112112
github: "osulli"
113-
- name: "dcowan-vestmark"
114-
github: "dcowan-vestmark"
115113

availability_zones.tf

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/terraform.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,23 @@
44
|------|-------------|:----:|:-----:|:-----:|
55
| additional_tag_map | Additional tags for appending to each tag map | map | `<map>` | no |
66
| attributes | Any extra attributes for naming these resources | list | `<list>` | no |
7-
| availability_zones | List of Availability Zones where subnets will be created. When none provided, all availability zones will be used up to the number provided in the public_subnet_count and/or private_subnet_count, and then will be reused if the number of subnets requested is more than the number of availability zones | list | `<list>` | no |
8-
| cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`), or pass in the vpc_id to use the CIDR from the VPC | string | `` | no |
7+
| availability_zones | List of Availability Zones where subnets will be created | list | - | yes |
8+
| cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`) | string | - | yes |
99
| context | The context output from an external label module to pass to the label modules within this module | map | `<map>` | no |
1010
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
1111
| environment | The environment name if not using stage | string | `` | no |
1212
| igw_id | Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`) | string | - | yes |
1313
| label_order | The naming order of the id output and Name tag | list | `<list>` | no |
1414
| map_public_ip_on_launch | Instances launched into a public subnet should be assigned a public IP address | string | `true` | no |
15-
| max_subnet_count | The maximum number of subnets to deploy. 0 for none, -1 to match the number of az's in the region, or a specific number | string | `-1` | no |
15+
| max_subnet_count | Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every provided availablility zone (in `availability_zones` variable) within the region | string | `0` | no |
1616
| name | Solution name, e.g. 'app' or 'jenkins' | string | `` | no |
1717
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no |
1818
| nat_gateway_enabled | Flag to enable/disable NAT Gateways to allow servers in the private subnets to access the Internet | string | `true` | no |
1919
| nat_instance_enabled | Flag to enable/disable NAT Instances to allow servers in the private subnets to access the Internet | string | `false` | no |
2020
| nat_instance_type | NAT Instance type | string | `t3.micro` | no |
2121
| private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no |
22-
| private_subnet_count | Sets the amount of private subnets to deploy. -1 will deploy a subnet for every availablility zone within the region, 0 will deploy no subnets. The AZ's supplied will be cycled through to create the subnets | string | `-1` | no |
2322
| public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no |
24-
| public_subnet_count | Sets the amount of public subnets to deploy. -1 will deploy a subnet for every availablility zone within the region, 0 will deploy no subnets. The AZ's supplied will be cycled through to create the subnets | string | `-1` | no |
2523
| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no |
26-
| region | The region to pass to the AWS provider nested in this module. | string | - | yes |
2724
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no |
2825
| subnet_type_tag_key | Key for subnet type tag to provide information about the type of subnets, e.g. `cpco.io/subnet/type=private` or `cpco.io/subnet/type=public` | string | `cpco.io/subnet/type` | no |
2926
| subnet_type_tag_value_format | This is using the format interpolation symbols to allow the value of the subnet_type_tag_key to be modified. | string | `%s` | no |
@@ -36,8 +33,6 @@
3633
| Name | Description |
3734
|------|-------------|
3835
| availability_zones | List of Availability Zones where subnets were created |
39-
| availability_zones_private | List of private Availability Zones where subnets were created |
40-
| availability_zones_public | List of public Availability Zones where subnets were created |
4136
| nat_gateway_ids | IDs of the NAT Gateways created |
4237
| nat_instance_ids | IDs of the NAT Instances created |
4338
| private_route_table_ids | IDs of the created private route tables |

example/main.tf

Lines changed: 0 additions & 86 deletions
This file was deleted.

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Any non-beta version >= 2.12.0 and < 2.13.0, e.g. 2.12.X
44
provider "aws" {
55
version = "~> 2.12.0"
6-
region = "${var.region}"
76
}
87

98
# Terraform
@@ -16,3 +15,5 @@ terraform {
1615
data "aws_vpc" "default" {
1716
id = "${var.vpc_id}"
1817
}
18+
19+
data "aws_availability_zones" "available" {}

nat-gateway.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module "nat_label" {
22
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.11.1"
33
context = "${module.label.context}"
4-
attributes = "${distinct(compact(concat(module.label.attributes,list("nat", "gateway"))))}"
4+
attributes = "${distinct(compact(concat(module.label.attributes,list("nat"))))}"
55
}
66

77
locals {
8-
nat_gateways_count = "${var.nat_gateway_enabled == "true" ? local.private_subnet_count : 0}"
8+
nat_gateways_count = "${var.nat_gateway_enabled == "true" ? length(var.availability_zones) : 0}"
99
}
1010

1111
resource "aws_eip" "default" {
1212
count = "${local.nat_gateways_count}"
1313
vpc = true
14-
tags = "${merge(module.private_label.tags, map("Name",format("%s%s%s", module.private_label.id, var.delimiter, replace(local.availability_zones_private[count.index % length(local.availability_zones_private)],"-",var.delimiter))))}"
14+
tags = "${merge(module.private_label.tags, map("Name",format("%s%s%s", module.private_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"
1515

1616
lifecycle {
1717
create_before_destroy = true
@@ -22,7 +22,7 @@ resource "aws_nat_gateway" "default" {
2222
count = "${local.nat_gateways_count}"
2323
allocation_id = "${element(aws_eip.default.*.id, count.index)}"
2424
subnet_id = "${element(aws_subnet.public.*.id, count.index)}"
25-
tags = "${merge(module.nat_label.tags, map("Name",format("%s%s%s", module.nat_label.id, var.delimiter, replace(local.availability_zones_private[count.index % length(local.availability_zones_private)],"-",var.delimiter))))}"
25+
tags = "${merge(module.nat_label.tags, map("Name",format("%s%s%s", module.nat_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"
2626

2727
lifecycle {
2828
create_before_destroy = true

0 commit comments

Comments
 (0)