Skip to content

Commit

Permalink
apply csi for all namspaces (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohanyadav authored Nov 21, 2024
1 parent 34ae8ec commit 7a07569
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions aws_csi_secrets_store.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,15 @@ resource "aws_iam_policy" "secrets_policy" {
}

data "aws_iam_policy_document" "trust_relationship" {
# Create a statement for each namespace
dynamic "statement" {
for_each = var.csi_enabled_namespaces
statement {
effect = "Allow"

content {
effect = "Allow"

principals {
type = "Federated"
identifiers = [local.oidc_provider_arn]
}

actions = ["sts:AssumeRoleWithWebIdentity"]

condition {
test = "StringEquals"
variable = "${replace(aws_eks_cluster.cluster.identity[0].oidc[0].issuer, "https://", "")}:aud"
values = ["sts.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "${replace(aws_eks_cluster.cluster.identity[0].oidc[0].issuer, "https://", "")}:sub"
values = ["system:serviceaccount:${statement.value}:csi-secrets-service-account"]
}
principals {
type = "Federated"
identifiers = [local.oidc_provider_arn]
}

actions = ["sts:AssumeRoleWithWebIdentity"]
}
}

Expand Down

0 comments on commit 7a07569

Please sign in to comment.