Skip to content

Instantly share code, notes, and snippets.

@anadimisra
Created September 16, 2023 17:49
Show Gist options
  • Save anadimisra/740e65063a4ac13aa094cf2463ac4aa4 to your computer and use it in GitHub Desktop.
Save anadimisra/740e65063a4ac13aa094cf2463ac4aa4 to your computer and use it in GitHub Desktop.
Terraform code to configure EBS volumes for EKS Nodes
resource "kubernetes_storage_class" "eks-ebs-storage-class" {
metadata {
name = "eks-ebs-storage-class"
}
parameters = {
type = "gp3"
}
storage_provisioner = "ebs.csi.aws.com"
reclaim_policy = "Delete"
volume_binding_mode = "WaitForFirstConsumer"
}
resource "kubernetes_service_account" "ebs-service-account" {
metadata {
name = "ebs-csi-controller-sa"
namespace = var.kube_namespace # the kube namespace is resolved from vairables in variables.tf and can be overridden in command line or via terraform.tfvars
labels = {
"app.kubernetes.io/name" = "ebs-csi-controller-sa"
}
annotations = {
# This annotation is only used when running on EKS which can use IAM roles for service accounts.
"eks.amazonaws.com/role-arn" = aws_iam_role.ebs-iam-role.arn
}
}
depends_on = [
aws_iam_role_policy_attachment.ebs-iam-role-policy-attachment
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment