Skip to content

Commit

Permalink
feat: inject additional AWS Identities (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Dibya Dhar <dibay.dhar@ensono.com>
  • Loading branch information
dibyadhar and Dibya Dhar committed Jun 6, 2024
1 parent e3f203f commit 051d482
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 11 additions & 15 deletions aws/modules/infrastructure_modules/eks/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ data "aws_caller_identity" "this" {}

data "aws_availability_zones" "available" {}

locals {

trusted_key_identities = var.trusted_role_arn == "" ? ["arn:aws:iam::${data.aws_caller_identity.this.account_id}:root"] : ["arn:aws:iam::${data.aws_caller_identity.this.account_id}:root", "${var.trusted_role_arn}"]
}

## EKS
data "aws_iam_policy_document" "eks_secret_encryption_kms_key_policy" {
statement {
sid = "Allow access for Key Administrators"
effect = "Allow"

principals {
type = "AWS"

identifiers = [
"arn:aws:iam::${data.aws_caller_identity.this.account_id}:root",
]
type = "AWS"
identifiers = local.trusted_key_identities
}

actions = [
Expand Down Expand Up @@ -42,11 +44,8 @@ data "aws_iam_policy_document" "eks_secret_encryption_kms_key_policy" {
effect = "Allow"

principals {
type = "AWS"

identifiers = [
"arn:aws:iam::${data.aws_caller_identity.this.account_id}:root",
]
type = "AWS"
identifiers = local.trusted_key_identities
}

actions = [
Expand All @@ -65,11 +64,8 @@ data "aws_iam_policy_document" "eks_secret_encryption_kms_key_policy" {
effect = "Allow"

principals {
type = "AWS"

identifiers = [
"arn:aws:iam::${data.aws_caller_identity.this.account_id}:root",
]
type = "AWS"
identifiers = local.trusted_key_identities
}

actions = [
Expand Down
5 changes: 5 additions & 0 deletions aws/modules/infrastructure_modules/eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ variable "cluster_security_group_additional_rules" {
}
}
}
variable "trusted_role_arn" {
description = "IAM role passed to KMS Policy"
type = string
default = ""
}

0 comments on commit 051d482

Please sign in to comment.