diff --git a/modules/vpc/README.md b/modules/vpc/README.md
index 7daa4cb..51125d7 100644
--- a/modules/vpc/README.md
+++ b/modules/vpc/README.md
@@ -17,13 +17,13 @@ For this reason, we recommend managing the tags externally of the resource itsel
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >=1.0.0 |
-| [aws](#requirement\_aws) | >= 3.45.0 |
+| [aws](#requirement\_aws) | >= 3.64.2 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 3.45.0 |
+| [aws](#provider\_aws) | >= 3.64.2 |
## Modules
@@ -52,11 +52,14 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [num\_azs](#input\_num\_azs) | The number of availability zones to provision | `number` | `2` | no |
-| [private\_subnet\_start](#input\_private\_subnet\_start) | n/a | `number` | `10` | no |
+| [private\_subnet\_newbits](#input\_private\_subnet\_newbits) | The number of bits to added to the VPC CIDR prefix. For instance, if your VPC CIDR is a /16 and you set this number to 8, the subnets will be /24s. | `number` | `8` | no |
+| [private\_subnet\_start](#input\_private\_subnet\_start) | The starting octet for the private subnet CIDR blocks generated by this module. | `number` | `10` | no |
| [public\_subnet\_auto\_ip](#input\_public\_subnet\_auto\_ip) | n/a | `bool` | `false` | no |
-| [public\_subnet\_start](#input\_public\_subnet\_start) | n/a | `number` | `20` | no |
+| [public\_subnet\_newbits](#input\_public\_subnet\_newbits) | The number of bits to added to the VPC CIDR prefix. For instance, if your VPC CIDR is a /16 and you set this number to 8, the subnets will be /24s. | `number` | `8` | no |
+| [public\_subnet\_start](#input\_public\_subnet\_start) | The starting octet for the public subnet CIDR blocks generated by this module. | `number` | `20` | no |
| [region](#input\_region) | n/a | `string` | n/a | yes |
-| [vpc\_cidr](#input\_vpc\_cidr) | n/a | `any` | n/a | yes |
+| [tags](#input\_tags) | Additional to apply to the resources. Note that this module sets the tags Name, Type, and Vendor by default. They can be overwritten, but it is not recommended. | `map(string)` | `{}` | no |
+| [vpc\_cidr](#input\_vpc\_cidr) | The CIDR range to be used by the AWS VPC. We recommend using a /16 prefix to automatically generate /24 subnets. If you are using a smaller or larger prefix, refer to the subnet\_newbits variable to ensure that the generated subnet ranges are a valid for EKS (minimum /24 is recommended). | `string` | n/a | yes |
| [vpc\_name](#input\_vpc\_name) | The name used for the VPC and associated resources | `string` | n/a | yes |
## Outputs
diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf
index 52177ab..3302ff7 100644
--- a/modules/vpc/main.tf
+++ b/modules/vpc/main.tf
@@ -35,7 +35,7 @@ resource "aws_vpc" "vpc" {
resource "aws_subnet" "public" {
count = var.num_azs
vpc_id = aws_vpc.vpc.id
- cidr_block = cidrsubnet(var.vpc_cidr, 8, var.public_subnet_start + count.index)
+ cidr_block = cidrsubnet(var.vpc_cidr, var.public_subnet_newbits, var.public_subnet_start + count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = var.public_subnet_auto_ip
tags = merge({ "Vendor" = "StreamNative", "Type" = "public", Name = format("%s-public-sbn-%s", var.vpc_name, count.index) }, var.tags)
@@ -48,7 +48,7 @@ resource "aws_subnet" "public" {
resource "aws_subnet" "private" {
count = var.num_azs
vpc_id = aws_vpc.vpc.id
- cidr_block = cidrsubnet(var.vpc_cidr, 8, var.private_subnet_start + count.index)
+ cidr_block = cidrsubnet(var.vpc_cidr, var.private_subnet_newbits, var.private_subnet_start + count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = merge({ "Vendor" = "StreamNative", "Type" = "private", Name = format("%s-private-sbn-%s", var.vpc_name, count.index) }, var.tags)
diff --git a/modules/vpc/variables.tf b/modules/vpc/variables.tf
index 29e7838..e7da9a9 100644
--- a/modules/vpc/variables.tf
+++ b/modules/vpc/variables.tf
@@ -37,13 +37,27 @@ variable "num_azs" {
}
variable "private_subnet_start" {
- type = number
- default = 10
+ default = 10
+ description = "The starting octet for the private subnet CIDR blocks generated by this module."
+ type = number
}
variable "public_subnet_start" {
- type = number
- default = 20
+ default = 20
+ description = "The starting octet for the public subnet CIDR blocks generated by this module."
+ type = number
+}
+
+variable "private_subnet_newbits" {
+ default = 8
+ description = "The number of bits to added to the VPC CIDR prefix. For instance, if your VPC CIDR is a /16 and you set this number to 8, the subnets will be /24s."
+ type = number
+}
+
+variable "public_subnet_newbits" {
+ default = 8
+ description = "The number of bits to added to the VPC CIDR prefix. For instance, if your VPC CIDR is a /16 and you set this number to 8, the subnets will be /24s."
+ type = number
}
variable "public_subnet_auto_ip" {
@@ -58,8 +72,6 @@ variable "tags" {
}
variable "vpc_cidr" {
- validation {
- condition = can(regex("^10\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/16", var.vpc_cidr))
- error_message = "The vpc_cidr must be a 10.x.x.x range with /16 CIDR."
- }
+ description = "The CIDR range to be used by the AWS VPC. We recommend using a /16 prefix to automatically generate /24 subnets. If you are using a smaller or larger prefix, refer to the subnet_newbits variable to ensure that the generated subnet ranges are a valid for EKS (minimum /24 is recommended)."
+ type = string
}