# # https://github.com/terraform-aws-modules/terraform-aws-eks-pod-identity module "aws_lb_controller_pod_identity" { source = "terraform-aws-modules/eks-pod-identity/aws" name = "aws-loadbalancer-controller" attach_aws_lb_controller_policy = true associations = { this = { cluster_name = module.eks.cluster_name namespace = "kube-system" service_account = "aws-load-balancer-controller-sa" } } } module "CsiPodIdentity" { source = "../modules/security_identity_compliance/iam-role-v2" description = "EKSCSIDriverRole" role-name = "AmazonEBSCSIDriverRole" trusted-entity = jsonencode( { "Version" : "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Principal" : { "Service" : "pods.eks.amazonaws.com" }, "Action" : [ "sts:AssumeRole", "sts:TagSession" ] } ] } ) } # 2 policies are required for the ebs csi to work resource "aws_iam_role_policy_attachment" "CsiPodIdentity" { for_each = toset([ "arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess", "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy" ]) role = module.CsiPodIdentity.name policy_arn = each.value }