From f0d6387fca642018d118030fd578506df3c31c89 Mon Sep 17 00:00:00 2001 From: Keyvan Date: Tue, 24 Dec 2024 13:08:30 +0100 Subject: [PATCH] Allow VPC subnet and CIDR to be configured --- cluster/README.md | 8 ++++---- cluster/variables.tf | 26 ++++++++++++++++++++++++++ cluster/vpc.tf | 15 +++------------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/cluster/README.md b/cluster/README.md index 17daba8..196b63a 100644 --- a/cluster/README.md +++ b/cluster/README.md @@ -66,16 +66,16 @@ | [environment](#input\_environment) | Environment name | `string` | `"dev"` | no | | [instance\_capacity\_type](#input\_instance\_capacity\_type) | Capacity type used by EKS managed node groups | `string` | `"SPOT"` | no | | [instance\_types](#input\_instance\_types) | List of instance types used by EKS managed node groups | `list(any)` |
[
"m5.large",
"m5d.large",
"m5a.large",
"m5ad.large",
"m4.large"
]
| no | +| [vpc\_cidr](#input\_vpc\_cidr) | VPC CIDR | `string` | `"10.0.0.0/16"` | no | +| [vpc\_private\_subnet\_cidr](#input\_vpc\_private\_subnet\_cidr) | List of private subnet configurations | `list(any)` |
[
"10.0.0.0/19",
"10.0.32.0/19",
"10.0.64.0/19"
]
| no | +| [vpc\_public\_subnet\_cidr](#input\_vpc\_public\_subnet\_cidr) | List of public subnet configurations | `list(any)` |
[
"10.0.96.0/19",
"10.0.128.0/19",
"10.0.160.0/19"
]
| no | | [worker\_node\_size](#input\_worker\_node\_size) | Node size of the worker node group | `map(number)` |
{
"desired": 2,
"max": 10,
"min": 0
}
| no | ## Outputs | Name | Description | |------|-------------| -| [radar\_base\_ebs\_storage\_class\_gp2](#output\_radar\_base\_ebs\_storage\_class\_gp2) | n/a | -| [radar\_base\_ebs\_storage\_class\_gp3](#output\_radar\_base\_ebs\_storage\_class\_gp3) | n/a | -| [radar\_base\_ebs\_storage\_class\_io1](#output\_radar\_base\_ebs\_storage\_class\_io1) | n/a | -| [radar\_base\_ebs\_storage\_class\_io2](#output\_radar\_base\_ebs\_storage\_class\_io2) | n/a | +| [radar\_base\_default\_storage\_class](#output\_radar\_base\_default\_storage\_class) | n/a | | [radar\_base\_eks\_cluser\_endpoint](#output\_radar\_base\_eks\_cluser\_endpoint) | n/a | | [radar\_base\_eks\_cluser\_kms\_key\_arn](#output\_radar\_base\_eks\_cluser\_kms\_key\_arn) | n/a | | [radar\_base\_eks\_cluster\_name](#output\_radar\_base\_eks\_cluster\_name) | n/a | diff --git a/cluster/variables.tf b/cluster/variables.tf index e487a71..aaf77fd 100644 --- a/cluster/variables.tf +++ b/cluster/variables.tf @@ -116,6 +116,32 @@ variable "dmz_node_size" { } } +variable "vpc_cidr" { + type = string + description = "VPC CIDR" + default = "10.0.0.0/16" +} + +variable "vpc_private_subnet_cidr" { + description = "List of private subnet configurations" + type = list(any) + default = [ + "10.0.0.0/19", + "10.0.32.0/19", + "10.0.64.0/19", + ] +} + +variable "vpc_public_subnet_cidr" { + description = "List of public subnet configurations" + type = list(any) + default = [ + "10.0.96.0/19", + "10.0.128.0/19", + "10.0.160.0/19", + ] +} + variable "defaut_storage_class" { type = string description = "Default storage class used for describing the EBS usage" diff --git a/cluster/vpc.tf b/cluster/vpc.tf index 9a605c9..664dc14 100644 --- a/cluster/vpc.tf +++ b/cluster/vpc.tf @@ -3,7 +3,7 @@ module "vpc" { version = "~> 5.0" name = "${var.eks_cluster_name}-vpc" - cidr = "10.0.0.0/16" + cidr = var.vpc_cidr azs = [ "${var.AWS_REGION}a", @@ -11,17 +11,8 @@ module "vpc" { "${var.AWS_REGION}c", ] - private_subnets = [ - "10.0.0.0/19", - "10.0.32.0/19", - "10.0.64.0/19", - ] - - public_subnets = [ - "10.0.96.0/19", - "10.0.128.0/19", - "10.0.160.0/19", - ] + private_subnets = var.vpc_private_subnet_cidr + public_subnets = var.vpc_public_subnet_cidr public_subnet_tags = { "kubernetes.io/role/elb" = "1"