Commit e47ee047 authored by Miguel Ferreira's avatar Miguel Ferreira Committed by GitHub

fix: Fix conditions with multiple subjects in assume role with oidc policy (#74)

parent 2f530de3
...@@ -21,4 +21,6 @@ module "iam_assumable_role_admin" { ...@@ -21,4 +21,6 @@ module "iam_assumable_role_admin" {
role_policy_arns = [ role_policy_arns = [
"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
] ]
oidc_fully_qualified_subjects = ["system:serviceaccount:default:sa1","system:serviceaccount:default:sa2"]
} }
...@@ -21,20 +21,21 @@ data "aws_iam_policy_document" "assume_role_with_oidc" { ...@@ -21,20 +21,21 @@ data "aws_iam_policy_document" "assume_role_with_oidc" {
} }
dynamic "condition" { dynamic "condition" {
for_each = var.oidc_fully_qualified_subjects for_each = length(var.oidc_fully_qualified_subjects) > 0 ? [1] : []
content { content {
test = "StringEquals" test = "StringEquals"
variable = "${var.provider_url}:sub" variable = "${var.provider_url}:sub"
values = [condition.value] values = var.oidc_fully_qualified_subjects
} }
} }
dynamic "condition" { dynamic "condition" {
for_each = var.oidc_subjects_with_wildcards for_each = length(var.oidc_subjects_with_wildcards) > 0 ? [1] : []
content { content {
test = "StringLike" test = "StringLike"
variable = "${var.provider_url}:sub" variable = "${var.provider_url}:sub"
values = [condition.value] values = var.oidc_subjects_with_wildcards
} }
} }
} }
......
...@@ -53,13 +53,13 @@ variable "role_policy_arns" { ...@@ -53,13 +53,13 @@ variable "role_policy_arns" {
variable "oidc_fully_qualified_subjects" { variable "oidc_fully_qualified_subjects" {
description = "The fully qualified OIDC subjects to be added to the role policy" description = "The fully qualified OIDC subjects to be added to the role policy"
type = list(string) type = set(string)
default = [] default = []
} }
variable "oidc_subjects_with_wildcards" { variable "oidc_subjects_with_wildcards" {
description = "The OIDC subject using wildcards to be added to the role policy" description = "The OIDC subject using wildcards to be added to the role policy"
type = list(string) type = set(string)
default = [] default = []
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment