Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 14, 2022 16:12
Show Gist options
  • Select an option

  • Save KyMidd/d2d85e4ae6a4cefe4cbb5f1bc70f6f62 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/d2d85e4ae6a4cefe4cbb5f1bc70f6f62 to your computer and use it in GitHub Desktop.
data "aws_iam_policy_document" "app1_eks_assume_role_policy" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.oid_provider.url, "https://", "")}:aud"
values = ["sts.amazonaws.com"]
}
# Condition to limit this role to be utilized by only the service account specified
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.oid_provider.url, "https://", "")}:sub"
values = ["system:serviceaccount:default:our-eks-sa-name"]
}
principals {
identifiers = [aws_iam_openid_connect_provider.oid_provider.arn]
type = "Federated"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment