@@ -2,7 +2,7 @@ terraform {
2
2
required_providers {
3
3
aws = {
4
4
source = " hashicorp/aws"
5
- version = " 5.67 .0"
5
+ version = " ~> 5 .0"
6
6
}
7
7
}
8
8
}
@@ -16,19 +16,13 @@ module "vpc" {
16
16
source = " terraform-aws-modules/vpc/aws"
17
17
version = " 5.16.0"
18
18
19
- create_vpc = var. create_vpc
20
-
21
19
name = " ${ var . name } -vpc"
22
20
cidr = " 10.0.0.0/16"
23
21
24
22
azs = [" ${ var . aws_region } a" , " ${ var . aws_region } b" , " ${ var . aws_region } c" ]
25
23
private_subnets = [" 10.0.1.0/24" , " 10.0.2.0/24" , " 10.0.3.0/24" ]
26
24
public_subnets = [" 10.0.101.0/24" , " 10.0.102.0/24" , " 10.0.103.0/24" ]
27
25
28
- create_database_subnet_group = true
29
- create_database_subnet_route_table = true
30
- create_database_internet_gateway_route = true
31
-
32
26
public_subnet_tags = {
33
27
" kubernetes.io/role/elb" = " 1"
34
28
}
@@ -44,14 +38,29 @@ module "vpc" {
44
38
# EKS Module
45
39
module "eks" {
46
40
source = " terraform-aws-modules/eks/aws"
47
- version = " ~> 19 .0"
41
+ version = " ~> 20 .0"
48
42
49
43
cluster_name = var. name
50
44
cluster_version = " 1.32"
51
45
52
46
vpc_id = module. vpc . vpc_id
53
47
subnet_ids = module. vpc . private_subnets
54
48
49
+ # Add-ons
50
+ cluster_addons = {
51
+ coredns = {}
52
+ kube-proxy = {}
53
+ vpc-cni = {}
54
+ aws-ebs-csi-driver = {
55
+ service_account_role_arn = module.ebs_csi_irsa.iam_role_arn
56
+ }
57
+ eks-pod-identity-agent = {}
58
+ }
59
+
60
+ cluster_endpoint_public_access = true
61
+ enable_cluster_creator_admin_permissions = true
62
+ enable_irsa = true
63
+
55
64
eks_managed_node_groups = {
56
65
standard = {
57
66
min_size = var.standard_min_size
@@ -79,23 +88,45 @@ module "eks" {
79
88
effect = " NO_SCHEDULE"
80
89
}
81
90
]
91
+
82
92
}
83
93
}
84
- cluster_endpoint_public_access = true
94
+ }
85
95
86
- # Add-ons
87
- cluster_addons = {
88
- coredns = {
89
- most_recent = true
90
- }
91
- kube-proxy = {
92
- most_recent = true
93
- }
94
- vpc-cni = {
95
- most_recent = true
96
- }
97
- aws-ebs-csi-driver = {
98
- most_recent = true
96
+ # Add this after your EKS module
97
+ resource "aws_security_group_rule" "node_to_node_all" {
98
+ description = " Allow nodes to communicate with each other on all ports"
99
+ type = " ingress"
100
+ from_port = 0
101
+ to_port = 65535
102
+ protocol = " -1"
103
+ source_security_group_id = module. eks . node_security_group_id
104
+ security_group_id = module. eks . node_security_group_id
105
+ }
106
+
107
+ resource "aws_security_group_rule" "vpc_cidr_ingress" {
108
+ description = " Allow all traffic from VPC CIDR"
109
+ type = " ingress"
110
+ from_port = 0
111
+ to_port = 65535
112
+ protocol = " -1"
113
+ cidr_blocks = [module . vpc . vpc_cidr_block ]
114
+ security_group_id = module. eks . node_security_group_id
115
+ }
116
+
117
+ module "ebs_csi_irsa" {
118
+ source = " terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
119
+ version = " ~> 5.0"
120
+
121
+ role_name = " ${ var . name } -ebs-csi-irsa"
122
+
123
+ # Bind the role to the cluster’s OIDC provider and the CSI controller SA
124
+ oidc_providers = {
125
+ main = {
126
+ provider_arn = module.eks.oidc_provider_arn
127
+ namespace_service_accounts = [" kube-system:ebs-csi-controller-sa" ]
99
128
}
100
129
}
130
+
131
+ attach_ebs_csi_policy = true
101
132
}
0 commit comments