File tree Expand file tree Collapse file tree 4 files changed +20
-16
lines changed Expand file tree Collapse file tree 4 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -9,18 +9,14 @@ module "vpc" {
99}
1010
1111module "eks" {
12- source = " ./modules/eks"
13-
14- cluster_name = var. cluster_name
12+ source = " ./modules/eks"
13+ cluster_name = var. cluster_name
1514 cluster_version = var. cluster_version
16- vpc_id = module. vpc . vpc_id
17- subnet_ids = module. vpc . private_subnet_ids
18- node_groups = var. node_groups
19-
20-
15+ vpc_id = module. vpc . vpc_id
16+ cluster_subnet_ids = concat (module. vpc . private_subnet_ids , module. vpc . public_subnet_ids )
17+ node_subnet_ids = module. vpc . private_subnet_ids
18+ node_groups = var. node_groups
2119}
22-
23- # EKS Addon: metrics-server (enables HPA CPU/memory metrics)
2420resource "aws_eks_addon" "metrics_server" {
2521 cluster_name = module. eks . cluster_name
2622 depends_on = [module . eks ]
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ resource "aws_eks_cluster" "main" {
99 }
1010
1111 vpc_config {
12- subnet_ids = var. subnet_ids
12+ subnet_ids = var. cluster_subnet_ids # Changed from var. subnet_ids
1313 }
1414
1515 depends_on = [
@@ -93,8 +93,7 @@ resource "aws_eks_node_group" "main" {
9393 cluster_name = aws_eks_cluster. main . name
9494 node_group_name = each. key
9595 node_role_arn = aws_iam_role. node . arn
96- subnet_ids = var. subnet_ids
97-
96+ subnet_ids = var. node_subnet_ids # Changed from var.subnet_ids
9897 scaling_config {
9998 desired_size = each. value . scaling_config . desired_size
10099 max_size = each. value . scaling_config . max_size
Original file line number Diff line number Diff line change @@ -13,11 +13,15 @@ variable "vpc_id" {
1313 type = string
1414}
1515
16- variable "subnet_ids " {
17- description = " Subnets IDS "
18- type = list (string )
16+ variable "cluster_subnet_ids " {
17+ description = " List of subnet IDs for EKS cluster (public + private) "
18+ type = list (string )
1919}
2020
21+ variable "node_subnet_ids" {
22+ description = " List of subnet IDs for EKS node groups (private only)"
23+ type = list (string )
24+ }
2125variable "node_groups" {
2226 description = " EKS node groups configuration"
2327 type = map (object ({
Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ resource "aws_nat_gateway" "main" {
7878 count = length (var. public_subnet_cidrs )
7979 allocation_id = aws_eip. nat [count . index ]. id
8080 subnet_id = aws_subnet. public [count . index ]. id
81+ depends_on = [
82+ aws_internet_gateway . main ,
83+ aws_subnet . public ,
84+ aws_eip . nat
85+ ] # Add this line
8186
8287 tags = {
8388 Name = " ${ var . cluster_name } -nat-${ count . index + 1 } "
You can’t perform that action at this time.
0 commit comments