Skip to content

Commit

Permalink
provision a way to promote AWS IAM users as kubernetes admins
Browse files Browse the repository at this point in the history
  • Loading branch information
iffyuva committed Sep 23, 2019
1 parent 7510375 commit fd8c679
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module "infra" {
source = "./modules/infra"

cluster_name = "${var.cluster_name}"
cluster_admins_arns = var.cluster_admins_arns
}

module "sw" {
Expand Down
8 changes: 8 additions & 0 deletions modules/infra/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ resource "kubernetes_config_map" "eks-nodes" {
# Generated mapRoles using https://github.com/sl1pm4t/k2tf
data = {
mapRoles = "- rolearn: ${aws_iam_role.eks-nodes.arn}\n username: system:node:{{EC2PrivateDNSName}}\n groups:\n - system:bootstrappers\n - system:nodes\n"

mapUsers = yamlencode([
for admin_arn in var.cluster_admins_arns : {
userarn = admin_arn
username = element(split("/", admin_arn), 1) # 0 indexed
groups = ["system:masters"]
}
])
}

depends_on = [aws_autoscaling_group.eks-nodes]
Expand Down
5 changes: 5 additions & 0 deletions modules/infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ variable "cluster_name" {
default = "dockup"
type = "string"
}

variable "cluster_admins_arns" {
default = [] # arns of users
type = "list"
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ variable "cluster_name" {
type = "string"
}

variable "cluster_admins_arns" {
default = [] # arns of users
type = "list"
}

variable "agent_key" {
default = "dockup-api-key"
type = "string"
Expand Down

0 comments on commit fd8c679

Please sign in to comment.