Skip to content

Feasibility to add additional trust policy on worker nodes #127

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_iam_role" "workers" {
name = coalesce(var.workers_iam_role, "${var.cluster_name}-workers")
description = "IAM Role for the workers in EKS Cluster named ${var.cluster_name}"

assume_role_policy = data.aws_iam_policy_document.ec2_assume_role_policy.json
assume_role_policy = data.aws_iam_policy_document.combined_assume_policy.json
permissions_boundary = var.workers_iam_boundary
force_detach_policies = true

Expand Down
16 changes: 16 additions & 0 deletions policies.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
locals {
source_policy_documents = length(var.workers_additional_assume_policy) > 0 ? [
data.aws_iam_policy_document.ec2_assume_role_policy.json,
data.aws_iam_policy_document.workers_additional_assume_policy.json
] : [data.aws_iam_policy_document.ec2_assume_role_policy.json]
}

data "aws_iam_policy_document" "eks_assume_role_policy" {
statement {
sid = "EKSClusterAssumeRole"
Expand All @@ -22,6 +29,15 @@ data "aws_iam_policy_document" "ec2_assume_role_policy" {
}
}

data "aws_iam_policy_document" "workers_additional_assume_policy" {
# Decode the JSON policy
source_policy_documents = [var.workers_additional_assume_policy]
}

data "aws_iam_policy_document" "combined_assume_policy" {
source_policy_documents = local.source_policy_documents
}

# This policy is required for the KMS key used for EKS root volumes, so the cluster is allowed to enc/dec/attach encrypted EBS volumes
data "aws_iam_policy_document" "kms_ebs" {
# Required for EKS
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ variable "iam_role_additional_policies" {
default = []
}

variable "workers_additional_assume_policy" {
description = "Additional Worker role Assume Policy JSON document"
type = string
default = ""
}

#######################
# Cluster RBAC (AWS Auth)
#######################
Expand Down
Loading