├── .github └── pull_request_template.md ├── .gitignore ├── main.tf ├── .travis.yml ├── docs ├── targets.md ├── terraform.md └── design.md ├── Makefile ├── outputs.tf ├── nat.tf ├── variables.tf ├── private.tf ├── public.tf ├── README.yaml ├── LICENSE └── README.md /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## what 2 | 3 | 4 | ## why 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled files 2 | *.tfstate 3 | *.tfstate.backup 4 | 5 | # Module directory 6 | .terraform 7 | .idea 8 | *.iml 9 | 10 | .build-harness 11 | build-harness -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.10.2" 3 | } 4 | 5 | # Get object aws_vpc by vpc_id 6 | data "aws_vpc" "default" { 7 | id = "${var.vpc_id}" 8 | } 9 | 10 | data "aws_availability_zones" "available" {} 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | addons: 2 | apt: 3 | packages: 4 | - git 5 | - make 6 | - curl 7 | 8 | install: 9 | - make init 10 | 11 | script: 12 | - make terraform/install 13 | - make terraform/get-plugins 14 | - make terraform/get-modules 15 | - make terraform/lint 16 | - make terraform/validate 17 | -------------------------------------------------------------------------------- /docs/targets.md: -------------------------------------------------------------------------------- 1 | ## Makefile Targets 2 | ``` 3 | Available targets: 4 | 5 | help Help screen 6 | help/all Display help for all targets 7 | help/short This help short screen 8 | lint Lint terraform code 9 | 10 | ``` 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | 3 | # List of targets the `readme` target should call before generating the readme 4 | export README_DEPS ?= docs/targets.md docs/terraform.md 5 | 6 | -include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) 7 | 8 | ## Lint terraform code 9 | lint: 10 | $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | output "public_subnet_ids" { 2 | description = "AWS IDs of the created public subnets" 3 | value = ["${aws_subnet.public.*.id}"] 4 | } 5 | 6 | output "private_subnet_ids" { 7 | description = "AWS IDs of the created private subnets" 8 | value = ["${aws_subnet.private.*.id}"] 9 | } 10 | 11 | output "public_subnet_cidrs" { 12 | description = "CIDR blocks of the created public subnets" 13 | value = ["${aws_subnet.public.*.cidr_block}"] 14 | } 15 | 16 | output "private_subnet_cidrs" { 17 | description = "CIDR blocks of the created private subnets" 18 | value = ["${aws_subnet.private.*.cidr_block}"] 19 | } 20 | 21 | output "public_route_table_ids" { 22 | description = "AWS IDs of the created public route tables" 23 | value = ["${aws_route_table.public.*.id}"] 24 | } 25 | 26 | output "private_route_table_ids" { 27 | description = "AWS IDs of the created private route tables" 28 | value = ["${aws_route_table.private.*.id}"] 29 | } 30 | 31 | output "nat_gateway_ids" { 32 | description = "AWS IDs of the NAT gateways created" 33 | value = ["${aws_nat_gateway.default.*.id}"] 34 | } 35 | 36 | output "availability_zones" { 37 | description = "List of Availability Zones where subnets were created" 38 | value = "${var.availability_zones}" 39 | } 40 | -------------------------------------------------------------------------------- /nat.tf: -------------------------------------------------------------------------------- 1 | module "nat_label" { 2 | source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3" 3 | namespace = "${var.namespace}" 4 | stage = "${var.stage}" 5 | name = "${var.name}" 6 | delimiter = "${var.delimiter}" 7 | attributes = "${compact(concat(var.attributes,list("nat")))}" 8 | tags = "${var.tags}" 9 | } 10 | 11 | locals { 12 | ## ORIGINAL SETTING ## 13 | 14 | # nat_gateways_count = "${var.nat_gateway_enabled == "true" ? length(var.availability_zones) : 0}" 15 | 16 | ## NAT ONLY IN ONE PUBLIC SUBNET ## 17 | 18 | nat_gateways_count = "${var.nat_gateway_enabled == "true" ? 1 : 0}" 19 | } 20 | 21 | resource "aws_eip" "default" { 22 | count = "${local.nat_gateways_count}" 23 | vpc = true 24 | 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))))}" 25 | 26 | lifecycle { 27 | create_before_destroy = true 28 | } 29 | } 30 | 31 | resource "aws_nat_gateway" "default" { 32 | count = "${local.nat_gateways_count}" 33 | allocation_id = "${element(aws_eip.default.*.id, count.index)}" 34 | subnet_id = "${element(aws_subnet.public.*.id, count.index)}" 35 | 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))))}" 36 | 37 | lifecycle { 38 | create_before_destroy = true 39 | } 40 | } 41 | 42 | # resource "aws_route" "default" { 43 | # count = "${local.nat_gateways_count}" 44 | # route_table_id = "${element(aws_route_table.private.*.id, count.index)}" 45 | # nat_gateway_id = "${element(aws_nat_gateway.default.*.id, count.index)}" 46 | # destination_cidr_block = "0.0.0.0/0" 47 | # depends_on = ["aws_route_table.private"] 48 | # } 49 | -------------------------------------------------------------------------------- /docs/terraform.md: -------------------------------------------------------------------------------- 1 | ## Inputs 2 | 3 | | Name | Description | Type | Default | Required | 4 | |------|-------------|:----:|:-----:|:-----:| 5 | | attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | 6 | | availability_zones | List of Availability Zones where subnets will be created | list | - | yes | 7 | | cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`) | string | - | yes | 8 | | delimiter | Delimiter to be used between `namespace`, `stage`, `name`, and `attributes` | string | `-` | no | 9 | | igw_id | Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`) | string | - | yes | 10 | | map_public_ip_on_launch | Instances launched into a public subnet should be assigned a public IP address | string | `true` | no | 11 | | max_subnet_count | Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every availablility zone within the region | string | `0` | no | 12 | | name | Name (e.g. `app`) | string | - | yes | 13 | | namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | 14 | | nat_gateway_enabled | Flag to enable/disable NAT gateways for private subnets | string | `true` | no | 15 | | private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no | 16 | | public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no | 17 | | region | AWS Region (e.g. `us-east-1`) | string | - | yes | 18 | | stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes | 19 | | 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 | 20 | | tags | Additional tags (e.g. map(`Cluster`,`XYZ`) | map | `` | no | 21 | | vpc_default_route_table_id | Default route table for public subnets. If not set, will be created. (e.g. `rtb-f4f0ce12`) | string | `` | no | 22 | | vpc_id | VPC ID where subnets will be created (e.g. `vpc-aceb2723`) | string | - | yes | 23 | 24 | ## Outputs 25 | 26 | | Name | Description | 27 | |------|-------------| 28 | | availability_zones | List of Availability Zones where subnets were created | 29 | | nat_gateway_ids | AWS IDs of the NAT gateways created | 30 | | private_route_table_ids | AWS IDs of the created private route tables | 31 | | private_subnet_cidrs | CIDR blocks of the created private subnets | 32 | | private_subnet_ids | AWS IDs of the created private subnets | 33 | | public_route_table_ids | AWS IDs of the created public route tables | 34 | | public_subnet_cidrs | CIDR blocks of the created public subnets | 35 | | public_subnet_ids | AWS IDs of the created public subnets | 36 | 37 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "namespace" { 2 | type = "string" 3 | description = "Namespace (e.g. `cp` or `cloudposse`)" 4 | } 5 | 6 | variable "stage" { 7 | type = "string" 8 | description = "Stage (e.g. `prod`, `dev`, `staging`)" 9 | } 10 | 11 | variable "name" { 12 | type = "string" 13 | description = "Name (e.g. `app`)" 14 | } 15 | 16 | variable "delimiter" { 17 | type = "string" 18 | default = "-" 19 | description = "Delimiter to be used between `namespace`, `stage`, `name`, and `attributes`" 20 | } 21 | 22 | variable "attributes" { 23 | type = "list" 24 | default = [] 25 | description = "Additional attributes (e.g. `policy` or `role`)" 26 | } 27 | 28 | variable "tags" { 29 | type = "map" 30 | default = {} 31 | description = "Additional tags (e.g. map(`Cluster`,`XYZ`)" 32 | } 33 | 34 | variable "subnet_type_tag_key" { 35 | default = "cpco.io/subnet/type" 36 | description = "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`" 37 | } 38 | 39 | variable "region" { 40 | type = "string" 41 | description = "AWS Region (e.g. `us-east-1`)" 42 | } 43 | 44 | variable "max_subnet_count" { 45 | default = 0 46 | description = "Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every availablility zone within the region" 47 | } 48 | 49 | variable "vpc_id" { 50 | type = "string" 51 | description = "VPC ID where subnets will be created (e.g. `vpc-aceb2723`)" 52 | } 53 | 54 | variable "igw_id" { 55 | type = "string" 56 | description = "Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`)" 57 | } 58 | 59 | variable "cidr_block" { 60 | type = "string" 61 | description = "Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`)" 62 | } 63 | 64 | variable "availability_zones" { 65 | type = "list" 66 | description = "List of Availability Zones where subnets will be created" 67 | } 68 | 69 | variable "vpc_default_route_table_id" { 70 | default = "" 71 | description = "Default route table for public subnets. If not set, will be created. (e.g. `rtb-f4f0ce12`)" 72 | } 73 | 74 | variable "public_network_acl_id" { 75 | default = "" 76 | description = "Network ACL ID that will be added to public subnets. If empty, a new ACL will be created" 77 | } 78 | 79 | variable "private_network_acl_id" { 80 | description = "Network ACL ID that will be added to private subnets. If empty, a new ACL will be created" 81 | default = "" 82 | } 83 | 84 | variable "nat_gateway_enabled" { 85 | description = "Flag to enable/disable NAT gateways for private subnets" 86 | default = "true" 87 | } 88 | 89 | variable "map_public_ip_on_launch" { 90 | default = "true" 91 | description = "Instances launched into a public subnet should be assigned a public IP address" 92 | } 93 | -------------------------------------------------------------------------------- /private.tf: -------------------------------------------------------------------------------- 1 | module "private_label" { 2 | source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3" 3 | namespace = "${var.namespace}" 4 | stage = "${var.stage}" 5 | name = "${var.name}" 6 | delimiter = "${var.delimiter}" 7 | attributes = "${compact(concat(var.attributes,list("private")))}" 8 | tags = "${merge(var.tags, map(var.subnet_type_tag_key, "private"))}" 9 | } 10 | 11 | module "private_subnet_label" { 12 | source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3" 13 | namespace = "${var.namespace}" 14 | stage = "${var.stage}" 15 | name = "${var.name}" 16 | attributes = "${compact(concat(var.attributes,list("private")))}" 17 | tags = "${merge(var.tags, map(var.subnet_type_tag_key, "private"))}" 18 | } 19 | 20 | locals { 21 | private_subnet_count = "${var.max_subnet_count == 0 ? length(data.aws_availability_zones.available.names) : var.max_subnet_count}" 22 | } 23 | 24 | resource "aws_subnet" "private" { 25 | count = "${length(var.availability_zones)}" 26 | vpc_id = "${data.aws_vpc.default.id}" 27 | availability_zone = "${element(var.availability_zones, count.index)}" 28 | cidr_block = "${cidrsubnet(signum(length(var.cidr_block)) == 1 ? var.cidr_block : data.aws_vpc.default.cidr_block, ceil(log(local.private_subnet_count * 2, 2)), count.index)}" 29 | 30 | tags = "${merge(module.private_subnet_label.tags, map("Name",format("%s%s%s", module.private_subnet_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}" 31 | 32 | lifecycle { 33 | # Ignore tags added by kops or kubernetes 34 | ignore_changes = ["tags.%", "tags.kubernetes", "tags.SubnetType"] 35 | } 36 | } 37 | 38 | resource "aws_route_table" "private" { 39 | count = "${length(var.availability_zones)}" 40 | vpc_id = "${data.aws_vpc.default.id}" 41 | 42 | route { 43 | cidr_block = "0.0.0.0/0" 44 | gateway_id = "${aws_nat_gateway.default.id}" 45 | } 46 | 47 | tags = "${merge(module.private_subnet_label.tags, map("Name",format("%s%s%s", module.private_subnet_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}" 48 | } 49 | 50 | resource "aws_route_table_association" "private" { 51 | count = "${length(var.availability_zones)}" 52 | 53 | subnet_id = "${element(aws_subnet.private.*.id, count.index)}" 54 | route_table_id = "${element(aws_route_table.private.*.id, count.index)}" 55 | } 56 | 57 | resource "aws_network_acl" "private" { 58 | count = "${signum(length(var.private_network_acl_id)) == 0 ? 1 : 0}" 59 | vpc_id = "${var.vpc_id}" 60 | subnet_ids = ["${aws_subnet.private.*.id}"] 61 | 62 | egress { 63 | rule_no = 100 64 | action = "allow" 65 | cidr_block = "0.0.0.0/0" 66 | from_port = 0 67 | to_port = 0 68 | protocol = "-1" 69 | } 70 | 71 | ingress { 72 | rule_no = 100 73 | action = "allow" 74 | cidr_block = "0.0.0.0/0" 75 | from_port = 0 76 | to_port = 0 77 | protocol = "-1" 78 | } 79 | 80 | tags = "${module.private_label.tags}" 81 | } 82 | -------------------------------------------------------------------------------- /docs/design.md: -------------------------------------------------------------------------------- 1 | ## Subnet calculation logic 2 | 3 | `terraform-aws-dynamic-subnets` creates a set of subnets based on `${var.cidr_block}` input and number of Availability Zones in the region. 4 | 5 | For subnet set calculation, the module uses Terraform interpolation 6 | 7 | [cidrsubnet](https://www.terraform.io/docs/configuration/interpolation.html#cidrsubnet-iprange-newbits-netnum-). 8 | 9 | 10 | ```hcl 11 | ${ 12 | cidrsubnet( 13 | signum(length(var.cidr_block)) == 1 ? 14 | var.cidr_block : data.aws_vpc.default.cidr_block, 15 | ceil(log(length(data.aws_availability_zones.available.names) * 2, 2)), 16 | count.index) 17 | } 18 | ``` 19 | 20 | 21 | 1. Use `${var.cidr_block}` input (if specified) or 22 | use a VPC CIDR block `data.aws_vpc.default.cidr_block` (e.g. `10.0.0.0/16`) 23 | 2. Get number of available AZ in the region (e.g. `length(data.aws_availability_zones.available.names)`) 24 | 3. Calculate `newbits`. `newbits` number specifies how many subnets 25 | be the CIDR block (input or VPC) will be divided into. `newbits` is the number of `binary digits`. 26 | 27 | Example: 28 | 29 | `newbits = 1` - 2 subnets are available (`1 binary digit` allows to count up to `2`) 30 | 31 | `newbits = 2` - 4 subnets are available (`2 binary digits` allows to count up to `4`) 32 | 33 | `newbits = 3` - 8 subnets are available (`3 binary digits` allows to count up to `8`) 34 | 35 | etc. 36 | 37 | 1. We know, that we have `6` AZs in a `us-east-1` region (see step 2). 38 | 2. We need to create `1 public` subnet and `1 private` subnet in each AZ, 39 | thus we need to create `12 subnets` in total (`6` AZs * (`1 public` + `1 private`)). 40 | 3. We need `4 binary digits` for that ( 24 = 16 ). 41 | In order to calculate the number of `binary digits` we should use `logarithm` 42 | function. We should use `base 2` logarithm because decimal numbers 43 | can be calculated as `powers` of binary number. 44 | See [Wiki](https://en.wikipedia.org/wiki/Binary_number#Decimal) 45 | for more details 46 | 47 | Example: 48 | 49 | For `12 subnets` we need `3.58` `binary digits` (log212) 50 | 51 | For `16 subnets` we need `4` `binary digits` (log216) 52 | 53 | For `7 subnets` we need `2.81` `binary digits` (log27) 54 | 55 | etc. 56 | 4. We can't use fractional values to calculate the number of `binary digits`. 57 | We can't round it down because smaller number of `binary digits` is 58 | insufficient to represent the required subnets. 59 | We round it up. See [ceil](https://www.terraform.io/docs/configuration/interpolation.html#ceil-float-). 60 | 61 | Example: 62 | 63 | For `12 subnets` we need `4` `binary digits` (ceil(log212)) 64 | 65 | For `16 subnets` we need `4` `binary digits` (ceil(log216)) 66 | 67 | For `7 subnets` we need `3` `binary digits` (ceil(log27)) 68 | 69 | etc. 70 | 71 | 5. Assign private subnets according to AZ number (we're using `count.index` for that). 72 | 6. Assign public subnets according to AZ number but with a shift according to the number of AZs in the region (see step 2) 73 | -------------------------------------------------------------------------------- /public.tf: -------------------------------------------------------------------------------- 1 | module "public_label" { 2 | source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3" 3 | namespace = "${var.namespace}" 4 | stage = "${var.stage}" 5 | name = "${var.name}" 6 | delimiter = "${var.delimiter}" 7 | attributes = "${compact(concat(var.attributes,list("public")))}" 8 | tags = "${merge(var.tags, map(var.subnet_type_tag_key, "public"))}" 9 | } 10 | 11 | module "public_subnet_label" { 12 | source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3" 13 | namespace = "${var.namespace}" 14 | stage = "${var.stage}" 15 | name = "${var.name}" 16 | attributes = "${compact(concat(var.attributes,list("public")))}" 17 | tags = "${merge(var.tags, map(var.subnet_type_tag_key, "public"))}" 18 | } 19 | 20 | locals { 21 | public_subnet_count = "${var.max_subnet_count == 0 ? length(data.aws_availability_zones.available.names) : var.max_subnet_count}" 22 | map_public_ip_on_launch = "${var.map_public_ip_on_launch == "true" ? true : false}" 23 | } 24 | 25 | resource "aws_subnet" "public" { 26 | count = "${length(var.availability_zones)}" 27 | vpc_id = "${data.aws_vpc.default.id}" 28 | availability_zone = "${element(var.availability_zones, count.index)}" 29 | cidr_block = "${cidrsubnet(signum(length(var.cidr_block)) == 1 ? var.cidr_block : data.aws_vpc.default.cidr_block, ceil(log(local.public_subnet_count * 2, 2)), local.public_subnet_count + count.index)}" 30 | map_public_ip_on_launch = "${local.map_public_ip_on_launch}" 31 | tags = "${merge(module.public_subnet_label.tags, map("Name",format("%s%s%s", module.public_subnet_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}" 32 | 33 | lifecycle { 34 | # Ignore tags added by kops or kubernetes 35 | ignore_changes = ["tags.%", "tags.kubernetes", "tags.SubnetType"] 36 | } 37 | } 38 | 39 | resource "aws_route_table" "public" { 40 | count = "${signum(length(var.vpc_default_route_table_id)) == 1 ? 0 : 1}" 41 | vpc_id = "${data.aws_vpc.default.id}" 42 | 43 | tags = "${module.public_label.tags}" 44 | } 45 | 46 | resource "aws_route" "public" { 47 | count = "${signum(length(var.vpc_default_route_table_id)) == 1 ? 0 : 1}" 48 | route_table_id = "${join("", aws_route_table.public.*.id)}" 49 | destination_cidr_block = "0.0.0.0/0" 50 | gateway_id = "${var.igw_id}" 51 | } 52 | 53 | resource "aws_route_table_association" "public" { 54 | count = "${signum(length(var.vpc_default_route_table_id)) == 1 ? 0 : length(var.availability_zones)}" 55 | subnet_id = "${element(aws_subnet.public.*.id, count.index)}" 56 | route_table_id = "${aws_route_table.public.id}" 57 | } 58 | 59 | resource "aws_route_table_association" "public_default" { 60 | count = "${signum(length(var.vpc_default_route_table_id)) == 1 ? length(var.availability_zones) : 0}" 61 | subnet_id = "${element(aws_subnet.public.*.id, count.index)}" 62 | route_table_id = "${var.vpc_default_route_table_id}" 63 | } 64 | 65 | resource "aws_network_acl" "public" { 66 | count = "${signum(length(var.public_network_acl_id)) == 0 ? 1 : 0}" 67 | vpc_id = "${var.vpc_id}" 68 | subnet_ids = ["${aws_subnet.public.*.id}"] 69 | 70 | egress { 71 | rule_no = 100 72 | action = "allow" 73 | cidr_block = "0.0.0.0/0" 74 | from_port = 0 75 | to_port = 0 76 | protocol = "-1" 77 | } 78 | 79 | ingress { 80 | rule_no = 100 81 | action = "allow" 82 | cidr_block = "0.0.0.0/0" 83 | from_port = 0 84 | to_port = 0 85 | protocol = "-1" 86 | } 87 | 88 | tags = "${module.public_label.tags}" 89 | } 90 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # This is the canonical configuration for the `README.md` 4 | # Run `make readme` to rebuild the `README.md` 5 | # 6 | 7 | # Name of this project 8 | name: terraform-aws-dynamic-subnets 9 | 10 | # Tags of this project 11 | tags: 12 | - aws 13 | - terraform 14 | - terraform-modules 15 | - networking 16 | - subnet 17 | - vpc 18 | - vpc-resources 19 | 20 | # Categories of this project 21 | categories: 22 | - terraform-modules/networking 23 | 24 | # Logo for this project 25 | #logo: docs/logo.png 26 | 27 | # License of this project 28 | license: "APACHE2" 29 | 30 | # Canonical GitHub repo 31 | github_repo: cloudposse/terraform-aws-dynamic-subnets 32 | 33 | # Badges to display 34 | badges: 35 | - name: "Build Status" 36 | image: "https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets.svg?branch=master" 37 | url: "https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets" 38 | - name: "Latest Release" 39 | image: "https://img.shields.io/github/release/cloudposse/terraform-aws-dynamic-subnets.svg" 40 | url: "https://github.com/cloudposse/terraform-aws-dynamic-subnets/releases/latest" 41 | - name: "Slack Community" 42 | image: "https://slack.cloudposse.com/badge.svg" 43 | url: "https://slack.cloudposse.com" 44 | 45 | related: 46 | - name: "terraform-aws-vpc" 47 | description: "Terraform Module that defines a VPC with public/private subnets across multiple AZs with Internet Gateways" 48 | url: "https://github.com/cloudposse/terraform-aws-vpc" 49 | - name: "terraform-aws-vpc-peering" 50 | description: "Terraform module to create a peering connection between two VPCs" 51 | url: "https://github.com/cloudposse/terraform-aws-vpc-peering" 52 | - name: "terraform-aws-kops-vpc-peering" 53 | description: "Terraform module to create a peering connection between a backing services VPC and a VPC created by Kops" 54 | url: "https://github.com/cloudposse/terraform-aws-kops-vpc-peering" 55 | - name: "terraform-aws-named-subnets" 56 | description: "Terraform module for named subnets provisioning." 57 | url: "https://github.com/cloudposse/terraform-aws-named-subnets" 58 | 59 | # Short description of this project 60 | description: |- 61 | Terraform module to provision public and private [`subnets`](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html) in an existing [`VPC`](https://aws.amazon.com/vpc) 62 | 63 | __Note:__ this module is intended for use with an existing VPC and existing Internet Gateway. 64 | To create a new VPC, use [terraform-aws-vpc](https://github.com/cloudposse/terraform-aws-vpc) module. 65 | 66 | # How to use this project 67 | usage: |- 68 | ```hcl 69 | module "subnets" { 70 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master" 71 | namespace = "cp" 72 | stage = "prod" 73 | name = "app" 74 | region = "us-east-1" 75 | vpc_id = "vpc-XXXXXXXX" 76 | igw_id = "igw-XXXXXXXX" 77 | cidr_block = "10.0.0.0/16" 78 | availability_zones = ["us-east-1a", "us-east-1b"] 79 | } 80 | ``` 81 | 82 | include: 83 | - "docs/design.md" 84 | - "docs/targets.md" 85 | - "docs/terraform.md" 86 | 87 | # Contributors to this project 88 | contributors: 89 | - name: "Erik Osterman" 90 | github: "osterman" 91 | - name: "Andriy Knysh" 92 | github: "aknysh" 93 | - name: "Sergey Vasilyev" 94 | github: "s2504s" 95 | - name: "Vladimir" 96 | github: "SweetOps" 97 | - name: "Konstantin B" 98 | github: "comeanother" 99 | - name: "dcowan-vestmark" 100 | github: "dcowan-vestmark" 101 | - name: "Ivan Pinatti" 102 | github: "ivan-pinatti" 103 | - name: "Oscar Sullivan" 104 | github: "osulli" 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017-2018 Cloud Posse, LLC 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![README Header][readme_header_img]][readme_header_link] 3 | 4 | [![Cloud Posse][logo]](https://cpco.io/homepage) 5 | 6 | # terraform-aws-dynamic-subnets [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-dynamic-subnets.svg)](https://github.com/cloudposse/terraform-aws-dynamic-subnets/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 7 | 8 | 9 | Terraform module to provision public and private [`subnets`](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html) in an existing [`VPC`](https://aws.amazon.com/vpc) 10 | 11 | __Note:__ this module is intended for use with an existing VPC and existing Internet Gateway. 12 | To create a new VPC, use [terraform-aws-vpc](https://github.com/cloudposse/terraform-aws-vpc) module. 13 | 14 | 15 | --- 16 | 17 | This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. 18 | [][share_email] 19 | [][share_googleplus] 20 | [][share_facebook] 21 | [][share_reddit] 22 | [][share_linkedin] 23 | [][share_twitter] 24 | 25 | 26 | [![Terraform Open Source Modules](https://docs.cloudposse.com/images/terraform-open-source-modules.svg)][terraform_modules] 27 | 28 | 29 | 30 | It's 100% Open Source and licensed under the [APACHE2](LICENSE). 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out! 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ## Usage 47 | 48 | ```hcl 49 | module "subnets" { 50 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master" 51 | namespace = "cp" 52 | stage = "prod" 53 | name = "app" 54 | region = "us-east-1" 55 | vpc_id = "vpc-XXXXXXXX" 56 | igw_id = "igw-XXXXXXXX" 57 | cidr_block = "10.0.0.0/16" 58 | availability_zones = ["us-east-1a", "us-east-1b"] 59 | } 60 | ``` 61 | 62 | 63 | 64 | 65 | 66 | 67 | ## Subnet calculation logic 68 | 69 | `terraform-aws-dynamic-subnets` creates a set of subnets based on `${var.cidr_block}` input and number of Availability Zones in the region. 70 | 71 | For subnet set calculation, the module uses Terraform interpolation 72 | 73 | [cidrsubnet](https://www.terraform.io/docs/configuration/interpolation.html#cidrsubnet-iprange-newbits-netnum-). 74 | 75 | 76 | ```hcl 77 | ${ 78 | cidrsubnet( 79 | signum(length(var.cidr_block)) == 1 ? 80 | var.cidr_block : data.aws_vpc.default.cidr_block, 81 | ceil(log(length(data.aws_availability_zones.available.names) * 2, 2)), 82 | count.index) 83 | } 84 | ``` 85 | 86 | 87 | 1. Use `${var.cidr_block}` input (if specified) or 88 | use a VPC CIDR block `data.aws_vpc.default.cidr_block` (e.g. `10.0.0.0/16`) 89 | 2. Get number of available AZ in the region (e.g. `length(data.aws_availability_zones.available.names)`) 90 | 3. Calculate `newbits`. `newbits` number specifies how many subnets 91 | be the CIDR block (input or VPC) will be divided into. `newbits` is the number of `binary digits`. 92 | 93 | Example: 94 | 95 | `newbits = 1` - 2 subnets are available (`1 binary digit` allows to count up to `2`) 96 | 97 | `newbits = 2` - 4 subnets are available (`2 binary digits` allows to count up to `4`) 98 | 99 | `newbits = 3` - 8 subnets are available (`3 binary digits` allows to count up to `8`) 100 | 101 | etc. 102 | 103 | 1. We know, that we have `6` AZs in a `us-east-1` region (see step 2). 104 | 2. We need to create `1 public` subnet and `1 private` subnet in each AZ, 105 | thus we need to create `12 subnets` in total (`6` AZs * (`1 public` + `1 private`)). 106 | 3. We need `4 binary digits` for that ( 24 = 16 ). 107 | In order to calculate the number of `binary digits` we should use `logarithm` 108 | function. We should use `base 2` logarithm because decimal numbers 109 | can be calculated as `powers` of binary number. 110 | See [Wiki](https://en.wikipedia.org/wiki/Binary_number#Decimal) 111 | for more details 112 | 113 | Example: 114 | 115 | For `12 subnets` we need `3.58` `binary digits` (log212) 116 | 117 | For `16 subnets` we need `4` `binary digits` (log216) 118 | 119 | For `7 subnets` we need `2.81` `binary digits` (log27) 120 | 121 | etc. 122 | 4. We can't use fractional values to calculate the number of `binary digits`. 123 | We can't round it down because smaller number of `binary digits` is 124 | insufficient to represent the required subnets. 125 | We round it up. See [ceil](https://www.terraform.io/docs/configuration/interpolation.html#ceil-float-). 126 | 127 | Example: 128 | 129 | For `12 subnets` we need `4` `binary digits` (ceil(log212)) 130 | 131 | For `16 subnets` we need `4` `binary digits` (ceil(log216)) 132 | 133 | For `7 subnets` we need `3` `binary digits` (ceil(log27)) 134 | 135 | etc. 136 | 137 | 5. Assign private subnets according to AZ number (we're using `count.index` for that). 138 | 6. Assign public subnets according to AZ number but with a shift according to the number of AZs in the region (see step 2) 139 | ## Makefile Targets 140 | ``` 141 | Available targets: 142 | 143 | help Help screen 144 | help/all Display help for all targets 145 | help/short This help short screen 146 | lint Lint terraform code 147 | 148 | ``` 149 | ## Inputs 150 | 151 | | Name | Description | Type | Default | Required | 152 | |------|-------------|:----:|:-----:|:-----:| 153 | | attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | 154 | | availability_zones | List of Availability Zones where subnets will be created | list | - | yes | 155 | | cidr_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`) | string | - | yes | 156 | | delimiter | Delimiter to be used between `namespace`, `stage`, `name`, and `attributes` | string | `-` | no | 157 | | igw_id | Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`) | string | - | yes | 158 | | map_public_ip_on_launch | Instances launched into a public subnet should be assigned a public IP address | string | `true` | no | 159 | | max_subnet_count | Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every availablility zone within the region | string | `0` | no | 160 | | name | Name (e.g. `app`) | string | - | yes | 161 | | namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | 162 | | nat_gateway_enabled | Flag to enable/disable NAT gateways for private subnets | string | `true` | no | 163 | | private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no | 164 | | public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no | 165 | | region | AWS Region (e.g. `us-east-1`) | string | - | yes | 166 | | stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes | 167 | | 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 | 168 | | tags | Additional tags (e.g. map(`Cluster`,`XYZ`) | map | `` | no | 169 | | vpc_default_route_table_id | Default route table for public subnets. If not set, will be created. (e.g. `rtb-f4f0ce12`) | string | `` | no | 170 | | vpc_id | VPC ID where subnets will be created (e.g. `vpc-aceb2723`) | string | - | yes | 171 | 172 | ## Outputs 173 | 174 | | Name | Description | 175 | |------|-------------| 176 | | availability_zones | List of Availability Zones where subnets were created | 177 | | nat_gateway_ids | AWS IDs of the NAT gateways created | 178 | | private_route_table_ids | AWS IDs of the created private route tables | 179 | | private_subnet_cidrs | CIDR blocks of the created private subnets | 180 | | private_subnet_ids | AWS IDs of the created private subnets | 181 | | public_route_table_ids | AWS IDs of the created public route tables | 182 | | public_subnet_cidrs | CIDR blocks of the created public subnets | 183 | | public_subnet_ids | AWS IDs of the created public subnets | 184 | 185 | 186 | 187 | 188 | ## Share the Love 189 | 190 | Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-dynamic-subnets)! (it helps us **a lot**) 191 | 192 | Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) 193 | 194 | 195 | ## Related Projects 196 | 197 | Check out these related projects. 198 | 199 | - [terraform-aws-vpc](https://github.com/cloudposse/terraform-aws-vpc) - Terraform Module that defines a VPC with public/private subnets across multiple AZs with Internet Gateways 200 | - [terraform-aws-vpc-peering](https://github.com/cloudposse/terraform-aws-vpc-peering) - Terraform module to create a peering connection between two VPCs 201 | - [terraform-aws-kops-vpc-peering](https://github.com/cloudposse/terraform-aws-kops-vpc-peering) - Terraform module to create a peering connection between a backing services VPC and a VPC created by Kops 202 | - [terraform-aws-named-subnets](https://github.com/cloudposse/terraform-aws-named-subnets) - Terraform module for named subnets provisioning. 203 | 204 | 205 | 206 | ## Help 207 | 208 | **Got a question?** 209 | 210 | File a GitHub [issue](https://github.com/cloudposse/terraform-aws-dynamic-subnets/issues), send us an [email][email] or join our [Slack Community][slack]. 211 | 212 | [![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] 213 | 214 | ## Commercial Support 215 | 216 | Work directly with our team of DevOps experts via email, slack, and video conferencing. 217 | 218 | We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer. 219 | 220 | [![E-Mail](https://img.shields.io/badge/email-hello@cloudposse.com-blue.svg)][email] 221 | 222 | - **Questions.** We'll use a Shared Slack channel between your team and ours. 223 | - **Troubleshooting.** We'll help you triage why things aren't working. 224 | - **Code Reviews.** We'll review your Pull Requests and provide constructive feedback. 225 | - **Bug Fixes.** We'll rapidly work to fix any bugs in our projects. 226 | - **Build New Terraform Modules.** We'll [develop original modules][module_development] to provision infrastructure. 227 | - **Cloud Architecture.** We'll assist with your cloud strategy and design. 228 | - **Implementation.** We'll provide hands-on support to implement our reference architectures. 229 | 230 | 231 | 232 | ## Terraform Module Development 233 | 234 | Are you interested in custom Terraform module development? Submit your inquiry using [our form][module_development] today and we'll get back to you ASAP. 235 | 236 | 237 | ## Slack Community 238 | 239 | Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. 240 | 241 | ## Newsletter 242 | 243 | Signup for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. 244 | 245 | ## Contributing 246 | 247 | ### Bug Reports & Feature Requests 248 | 249 | Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-dynamic-subnets/issues) to report any bugs or file feature requests. 250 | 251 | ### Developing 252 | 253 | If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. 254 | 255 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 256 | 257 | 1. **Fork** the repo on GitHub 258 | 2. **Clone** the project to your own machine 259 | 3. **Commit** changes to your own branch 260 | 4. **Push** your work back up to your fork 261 | 5. Submit a **Pull Request** so that we can review your changes 262 | 263 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! 264 | 265 | 266 | ## Copyright 267 | 268 | Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright) 269 | 270 | 271 | 272 | ## License 273 | 274 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 275 | 276 | See [LICENSE](LICENSE) for full details. 277 | 278 | Licensed to the Apache Software Foundation (ASF) under one 279 | or more contributor license agreements. See the NOTICE file 280 | distributed with this work for additional information 281 | regarding copyright ownership. The ASF licenses this file 282 | to you under the Apache License, Version 2.0 (the 283 | "License"); you may not use this file except in compliance 284 | with the License. You may obtain a copy of the License at 285 | 286 | https://www.apache.org/licenses/LICENSE-2.0 287 | 288 | Unless required by applicable law or agreed to in writing, 289 | software distributed under the License is distributed on an 290 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 291 | KIND, either express or implied. See the License for the 292 | specific language governing permissions and limitations 293 | under the License. 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | ## Trademarks 304 | 305 | All other trademarks referenced herein are the property of their respective owners. 306 | 307 | ## About 308 | 309 | This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! 310 | 311 | [![Cloud Posse][logo]][website] 312 | 313 | We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. 314 | 315 | We offer [paid support][commercial_support] on all of our projects. 316 | 317 | Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. 318 | 319 | 320 | 321 | ### Contributors 322 | 323 | | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]
[Sergey Vasilyev][s2504s_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]
[Vladimir][SweetOps_homepage] | [![Konstantin B][comeanother_avatar]][comeanother_homepage]
[Konstantin B][comeanother_homepage] | [![dcowan-vestmark][dcowan-vestmark_avatar]][dcowan-vestmark_homepage]
[dcowan-vestmark][dcowan-vestmark_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]
[Ivan Pinatti][ivan-pinatti_homepage] | [![Oscar Sullivan][osulli_avatar]][osulli_homepage]
[Oscar Sullivan][osulli_homepage] | 324 | |---|---|---|---|---|---|---|---| 325 | 326 | [osterman_homepage]: https://github.com/osterman 327 | [osterman_avatar]: https://github.com/osterman.png?size=150 328 | [aknysh_homepage]: https://github.com/aknysh 329 | [aknysh_avatar]: https://github.com/aknysh.png?size=150 330 | [s2504s_homepage]: https://github.com/s2504s 331 | [s2504s_avatar]: https://github.com/s2504s.png?size=150 332 | [SweetOps_homepage]: https://github.com/SweetOps 333 | [SweetOps_avatar]: https://github.com/SweetOps.png?size=150 334 | [comeanother_homepage]: https://github.com/comeanother 335 | [comeanother_avatar]: https://github.com/comeanother.png?size=150 336 | [dcowan-vestmark_homepage]: https://github.com/dcowan-vestmark 337 | [dcowan-vestmark_avatar]: https://github.com/dcowan-vestmark.png?size=150 338 | [ivan-pinatti_homepage]: https://github.com/ivan-pinatti 339 | [ivan-pinatti_avatar]: https://github.com/ivan-pinatti.png?size=150 340 | [osulli_homepage]: https://github.com/osulli 341 | [osulli_avatar]: https://github.com/osulli.png?size=150 342 | 343 | 344 | 345 | [![README Footer][readme_footer_img]][readme_footer_link] 346 | [![Beacon][beacon]][website] 347 | 348 | [logo]: https://cloudposse.com/logo-300x69.svg 349 | [docs]: https://cpco.io/docs 350 | [website]: https://cpco.io/homepage 351 | [github]: https://cpco.io/github 352 | [jobs]: https://cpco.io/jobs 353 | [hire]: https://cpco.io/hire 354 | [slack]: https://cpco.io/slack 355 | [linkedin]: https://cpco.io/linkedin 356 | [twitter]: https://cpco.io/twitter 357 | [testimonial]: https://cpco.io/leave-testimonial 358 | [newsletter]: https://cpco.io/newsletter 359 | [email]: https://cpco.io/email 360 | [commercial_support]: https://cpco.io/commercial-support 361 | [we_love_open_source]: https://cpco.io/we-love-open-source 362 | [module_development]: https://cpco.io/module-development 363 | [terraform_modules]: https://cpco.io/terraform-modules 364 | [readme_header_img]: https://cloudposse.com/readme/header/img?repo=cloudposse/terraform-aws-dynamic-subnets 365 | [readme_header_link]: https://cloudposse.com/readme/header/link?repo=cloudposse/terraform-aws-dynamic-subnets 366 | [readme_footer_img]: https://cloudposse.com/readme/footer/img?repo=cloudposse/terraform-aws-dynamic-subnets 367 | [readme_footer_link]: https://cloudposse.com/readme/footer/link?repo=cloudposse/terraform-aws-dynamic-subnets 368 | [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img?repo=cloudposse/terraform-aws-dynamic-subnets 369 | [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?repo=cloudposse/terraform-aws-dynamic-subnets 370 | [share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-dynamic-subnets&url=https://github.com/cloudposse/terraform-aws-dynamic-subnets 371 | [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-dynamic-subnets&url=https://github.com/cloudposse/terraform-aws-dynamic-subnets 372 | [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-dynamic-subnets 373 | [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-dynamic-subnets 374 | [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-dynamic-subnets 375 | [share_email]: mailto:?subject=terraform-aws-dynamic-subnets&body=https://github.com/cloudposse/terraform-aws-dynamic-subnets 376 | [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-dynamic-subnets?pixel&cs=github&cm=readme&an=terraform-aws-dynamic-subnets 377 | --------------------------------------------------------------------------------