Skip to content

Commit 56b324b

Browse files
committed
feature: updated aws-eks module and set iam roles for cluster add-ons
needed
1 parent b9c6552 commit 56b324b

File tree

4 files changed

+57
-155
lines changed

4 files changed

+57
-155
lines changed

terraform/aws/trieve-aws/helm.tf

Lines changed: 0 additions & 116 deletions
This file was deleted.

terraform/aws/trieve-aws/main.tf

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
aws = {
44
source = "hashicorp/aws"
5-
version = "5.67.0"
5+
version = "~> 5.0"
66
}
77
}
88
}
@@ -16,19 +16,13 @@ module "vpc" {
1616
source = "terraform-aws-modules/vpc/aws"
1717
version = "5.16.0"
1818

19-
create_vpc = var.create_vpc
20-
2119
name = "${var.name}-vpc"
2220
cidr = "10.0.0.0/16"
2321

2422
azs = ["${var.aws_region}a", "${var.aws_region}b", "${var.aws_region}c"]
2523
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
2624
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
2725

28-
create_database_subnet_group = true
29-
create_database_subnet_route_table = true
30-
create_database_internet_gateway_route = true
31-
3226
public_subnet_tags = {
3327
"kubernetes.io/role/elb" = "1"
3428
}
@@ -44,14 +38,29 @@ module "vpc" {
4438
# EKS Module
4539
module "eks" {
4640
source = "terraform-aws-modules/eks/aws"
47-
version = "~> 19.0"
41+
version = "~> 20.0"
4842

4943
cluster_name = var.name
5044
cluster_version = "1.32"
5145

5246
vpc_id = module.vpc.vpc_id
5347
subnet_ids = module.vpc.private_subnets
5448

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+
5564
eks_managed_node_groups = {
5665
standard = {
5766
min_size = var.standard_min_size
@@ -79,23 +88,45 @@ module "eks" {
7988
effect = "NO_SCHEDULE"
8089
}
8190
]
91+
8292
}
8393
}
84-
cluster_endpoint_public_access = true
94+
}
8595

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"]
99128
}
100129
}
130+
131+
attach_ebs_csi_policy = true
101132
}

terraform/aws/trieve-aws/variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
variable "create_vpc" {
2-
type = bool
3-
default = true
4-
}
5-
61
variable "aws_region" {
72
type = string
83
default = "us-west-2"
@@ -52,9 +47,3 @@ variable "standard_desired_capacity" {
5247
type = number
5348
default = 2
5449
}
55-
56-
variable "install_alb_controller" {
57-
type = bool
58-
default = true
59-
description = "Whether to install the AWS Load Balancer Controller"
60-
}

terraform/aws/trieve.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module "trieve" {
22
source = "./trieve-aws"
33

44
# General Configuration
5-
aws_region = "us-east-1"
5+
aws_region = "us-west-2"
66
name = "trieve-aws-cluster"
77

88
# EKS Node Group Configuration
@@ -11,10 +11,8 @@ module "trieve" {
1111
gpu_min_size = 1
1212
gpu_desired_capacity = 5
1313

14-
instance_type_standard = "c7a.xlarge"
15-
standard_max_size = 3
14+
instance_type_standard = "c7a.2xlarge"
15+
standard_max_size = 2
1616
standard_min_size = 0
17-
standard_desired_capacity = 1
18-
# Application Load Balancer
19-
install_alb_controller = true
17+
standard_desired_capacity = 2
2018
}

0 commit comments

Comments
 (0)