diff --git a/aws/_modules/eks/variables.tf b/aws/_modules/eks/variables.tf index 27bc75cd..2ba3c3c9 100644 --- a/aws/_modules/eks/variables.tf +++ b/aws/_modules/eks/variables.tf @@ -18,6 +18,16 @@ variable "availability_zones" { type = list(string) } +variable "vpc_cidr" { + description = "CIDR to use for the VPC." + type = string +} + +variable "vpc_subnet_newbits" { + description = "CIDR to use for the VPC." + type = string +} + variable "instance_type" { description = "AWS instance type to use for worker nodes." type = string diff --git a/aws/_modules/eks/vpc.tf b/aws/_modules/eks/vpc.tf index f1c9b50f..2555cfb8 100644 --- a/aws/_modules/eks/vpc.tf +++ b/aws/_modules/eks/vpc.tf @@ -1,5 +1,5 @@ resource "aws_vpc" "current" { - cidr_block = "10.0.0.0/16" + cidr_block = var.vpc_cidr tags = local.eks_metadata_tags } @@ -8,7 +8,7 @@ resource "aws_subnet" "current" { count = length(var.availability_zones) availability_zone = var.availability_zones[count.index] - cidr_block = "10.0.${count.index}.0/24" + cidr_block = cidrsubnet(aws_vpc.current.cidr_block, var.vpc_subnet_newbits, count.index) vpc_id = aws_vpc.current.id map_public_ip_on_launch = true diff --git a/aws/cluster/configuration.tf b/aws/cluster/configuration.tf index 13b4a9d6..82a28cf7 100644 --- a/aws/cluster/configuration.tf +++ b/aws/cluster/configuration.tf @@ -16,6 +16,9 @@ locals { cluster_availability_zones_lookup = lookup(local.cfg, "cluster_availability_zones", "") cluster_availability_zones = split(",", local.cluster_availability_zones_lookup) + cluster_vpc_cidr = lookup(local.cfg, "cluster_vpc_cidr", "10.0.0.0/16") + cluster_vpc_subnet_newbits = lookup(local.cfg, "cluster_vpc_subnet_newbits", "8") + cluster_instance_type = local.cfg["cluster_instance_type"] cluster_desired_capacity = local.cfg["cluster_desired_capacity"] diff --git a/aws/cluster/main.tf b/aws/cluster/main.tf index 86554232..2a295ab4 100644 --- a/aws/cluster/main.tf +++ b/aws/cluster/main.tf @@ -19,11 +19,14 @@ module "cluster" { metadata_labels = module.cluster_metadata.labels availability_zones = local.cluster_availability_zones - instance_type = local.cluster_instance_type - desired_capacity = local.cluster_desired_capacity - max_size = local.cluster_max_size - min_size = local.cluster_min_size - cluster_version = local.cluster_version + vpc_cidr = local.cluster_vpc_cidr + vpc_subnet_newbits = local.cluster_vpc_subnet_newbits + + instance_type = local.cluster_instance_type + desired_capacity = local.cluster_desired_capacity + max_size = local.cluster_max_size + min_size = local.cluster_min_size + cluster_version = local.cluster_version root_device_encrypted = local.worker_root_device_encrypted root_device_volume_size = local.worker_root_device_volume_size