|
1 |
| -# These EBS-CSI plugin configs are here because they require the Kubernetes TF |
2 |
| -# plugin, which needs to be configured with information from the 0-hardware stage |
| 1 | +# The EBS CSI plugin IRSA configs are here, and not in 0—hardware where the EBS |
| 2 | +# CSI plugin was installed, because they require the Kubernetes TF provider, |
| 3 | +# which needs to be configured with outputs from the 0-hardware stage |
3 | 4 | module "ebs_csi_irsa" {
|
4 | 5 | source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
|
5 | 6 |
|
@@ -27,3 +28,71 @@ resource "kubernetes_annotations" "ebs_csi_iam_annotation" {
|
27 | 28 | "eks.amazonaws.com/role-arn": module.ebs_csi_irsa.iam_role_arn
|
28 | 29 | }
|
29 | 30 | }
|
| 31 | + |
| 32 | +module "efs_csi_irsa" { |
| 33 | + count = local.use_efs |
| 34 | + |
| 35 | + source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" |
| 36 | + |
| 37 | + role_name_prefix = "efs-csi-${local.cluster_name}" |
| 38 | + attach_efs_csi_policy = true |
| 39 | + |
| 40 | + oidc_providers = { |
| 41 | + main = { |
| 42 | + provider_arn = module.eks.oidc_provider_arn |
| 43 | + namespace_service_accounts = [ |
| 44 | + "kube-system:efs-csi-controller-sa" |
| 45 | + ] |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + tags = local.tags |
| 50 | +} |
| 51 | + |
| 52 | +module "efs_csi_irsa_node" { |
| 53 | + count = local.use_efs |
| 54 | + |
| 55 | + source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" |
| 56 | + |
| 57 | + role_name_prefix = "efs-csi-node-${local.cluster_name}" |
| 58 | + attach_efs_csi_policy = true |
| 59 | + |
| 60 | + oidc_providers = { |
| 61 | + main = { |
| 62 | + provider_arn = module.eks.oidc_provider_arn |
| 63 | + namespace_service_accounts = [ |
| 64 | + "kube-system:efs-csi-node-sa" |
| 65 | + ] |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + tags = local.tags |
| 70 | +} |
| 71 | + |
| 72 | +resource "kubernetes_annotations" "efs_csi_iam_annotation" { |
| 73 | + count = local.use_efs |
| 74 | + |
| 75 | + api_version = "v1" |
| 76 | + kind = "ServiceAccount" |
| 77 | + metadata { |
| 78 | + name = "efs-csi-controller-sa" |
| 79 | + namespace = "kube-system" |
| 80 | + } |
| 81 | + annotations = { |
| 82 | + "eks.amazonaws.com/role-arn": module.efs_csi_irsa[0].iam_role_arn |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +resource "kubernetes_annotations" "efs_csi_node_annotation" { |
| 87 | + count = local.use_efs |
| 88 | + |
| 89 | + api_version = "v1" |
| 90 | + kind = "ServiceAccount" |
| 91 | + metadata { |
| 92 | + name = "efs-csi-node-sa" |
| 93 | + namespace = "kube-system" |
| 94 | + } |
| 95 | + annotations = { |
| 96 | + "eks.amazonaws.com/role-arn": module.efs_csi_irsa_node[0].iam_role_arn |
| 97 | + } |
| 98 | +} |
0 commit comments