Skip to content

Commit 3c7f28d

Browse files
committed
Allow for the FSx CSI driver to be selectively installed
1 parent c195b84 commit 3c7f28d

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

deployment/aws-terraform/1-services/fsx-csi.tf

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
resource "helm_release" "fsx_csi_driver" {
2+
count = local.use_fsx
23
namespace = "kube-system"
34

45
name = "aws-fsx-csi-driver"
56
repository = "https://kubernetes-sigs.github.io/aws-fsx-csi-driver/"
67
chart = "aws-fsx-csi-driver"
8+
9+
set {
10+
name = "controller.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
11+
value = module.fsx_csi_irsa[0].iam_role_arn
12+
}
13+
14+
set {
15+
name = "node.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
16+
value = module.fsx_csi_irsa[0].iam_role_arn
17+
}
718
}
819

920
resource "kubernetes_storage_class_v1" "fsx_sc" {
21+
count = local.use_fsx
1022
metadata {
1123
name = "fsx-sc"
1224
}
@@ -16,5 +28,5 @@ resource "kubernetes_storage_class_v1" "fsx_sc" {
1628
securityGroupIds = module.eks.cluster_security_group
1729
deploymentType = "PERSISTENT_2"
1830
}
19-
depends_on = [ helm_release.fsx_csi_driver ]
31+
depends_on = [ helm_release.fsx_csi_driver[0] ]
2032
}

deployment/aws-terraform/1-services/irsa.tf

+16-10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ module "efs_csi_irsa" {
5050
}
5151

5252
module "fsx_csi_irsa" {
53+
count = local.use_fsx
54+
5355
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
5456

5557
role_name_prefix = "fsx-csi-${local.cluster_name}"
@@ -112,15 +114,19 @@ resource "kubernetes_annotations" "efs_csi_node_annotation" {
112114
}
113115
annotations = {
114116
"eks.amazonaws.com/role-arn": module.efs_csi_irsa_node[0].iam_role_arn
115-
116-
resource "kubernetes_annotations" "fsx_csi_controller_annotation" {
117-
api_version = "v1"
118-
kind = "ServiceAccount"
119-
metadata {
120-
name = "fsx-csi-controller-sa"
121-
namespace = "kube-system"
122-
}
123-
annotations = {
124-
"eks.amazonaws.com/role-arn": module.fsx_csi_irsa.iam_role_arn
125117
}
126118
}
119+
120+
# resource "kubernetes_annotations" "fsx_csi_controller_annotation" {
121+
# count = local.use_fsx
122+
123+
# api_version = "v1"
124+
# kind = "ServiceAccount"
125+
# metadata {
126+
# name = "fsx-csi-controller-sa"
127+
# namespace = "kube-system"
128+
# }
129+
# annotations = {
130+
# "eks.amazonaws.com/role-arn": module.fsx_csi_irsa[0].iam_role_arn
131+
# }
132+
# }

deployment/aws-terraform/1-services/locals.tf

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ locals {
33
db_count = var.create_rds_instance ? 1 : 0
44
cognito_pool_count = var.create_cognito_pool ? 1 : 0
55
use_efs = var.use_efs_csi ? 1 : 0
6+
use_fsx = var.use_fsx_csi ? 1 : 0
67

78
tags = {
89
Name = var.project_prefix

deployment/aws-terraform/1-services/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ variable "use_efs_csi" {
5050
default = false
5151
}
5252

53+
variable "use_fsx_csi" {
54+
type = bool
55+
description = "Install CSI driver for FSx for Lustre volumes"
56+
default = false
57+
}
58+
5359
variable "r53_rds_private_hosted_zone" {
5460
type = string
5561
default = null

0 commit comments

Comments
 (0)