Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current role as Cluster Admin using CAM #1005

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cluster/terraform/eks.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
data "aws_caller_identity" "current" {}

data "aws_iam_role" "current_role" {
name = element(split("/", data.aws_caller_identity.current.arn), 1)
}

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
Expand Down Expand Up @@ -53,4 +59,20 @@ module "eks" {
tags = merge(local.tags, {
"karpenter.sh/discovery" = var.cluster_name
})
}

resource "aws_eks_access_entry" "cloud9_role" {
cluster_name = var.cluster_name
principal_arn = data.aws_iam_role.current_role.arn
type = "STANDARD"
}

resource "aws_eks_access_policy_association" "cloud9_role_policy" {
cluster_name = var.cluster_name
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
principal_arn = data.aws_iam_role.current_role.arn

access_scope {
type = "cluster"
}
}