Skip to content

Commit 8469c03

Browse files
authored
feat: Add variable to change IAM condition test operator to suite; defaults to StringEquals (#201)
1 parent 66c80ff commit 8469c03

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

modules/iam-role-for-service-accounts-eks/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ module "iam_eks_role" {
2020
2121
oidc_providers = {
2222
one = {
23-
provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D"
24-
service_accounts = ["default:my-app-staging", "canary:my-app-staging"]
23+
provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D"
24+
namespace_service_accounts = ["default:my-app-staging", "canary:my-app-staging"]
2525
}
2626
two = {
27-
provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G"
28-
service_accounts = ["default:my-app-staging"]
27+
provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.ap-southeast-1.amazonaws.com/id/5C54DDF35ER54476848E7333374FF09G"
28+
namespace_service_accounts = ["default:my-app-staging"]
2929
}
3030
}
3131
}
@@ -44,8 +44,8 @@ module "vpc_cni_irsa_role" {
4444
4545
oidc_providers = {
4646
main = {
47-
provider_arn = module.eks.oidc_provider_arn
48-
service_accounts = ["default:my-app", "canary:my-app"]
47+
provider_arn = module.eks.oidc_provider_arn
48+
namespace_service_accounts = ["default:my-app", "canary:my-app"]
4949
}
5050
}
5151
}
@@ -64,8 +64,8 @@ module "karpenter_irsa_role" {
6464
6565
oidc_providers = {
6666
main = {
67-
provider_arn = module.eks.oidc_provider_arn
68-
service_accounts = ["default:my-app", "canary:my-app"]
67+
provider_arn = module.eks.oidc_provider_arn
68+
namespace_service_accounts = ["default:my-app", "canary:my-app"]
6969
}
7070
}
7171
}
@@ -138,6 +138,7 @@ No modules.
138138

139139
| Name | Description | Type | Default | Required |
140140
|------|-------------|------|---------|:--------:|
141+
| <a name="input_assume_role_condition_test"></a> [assume\_role\_condition\_test](#input\_assume\_role\_condition\_test) | Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role | `string` | `"StringEquals"` | no |
141142
| <a name="input_attach_cluster_autoscaler_policy"></a> [attach\_cluster\_autoscaler\_policy](#input\_attach\_cluster\_autoscaler\_policy) | Determines whether to attach the Cluster Autoscaler IAM policy to the role | `bool` | `false` | no |
142143
| <a name="input_attach_ebs_csi_policy"></a> [attach\_ebs\_csi\_policy](#input\_attach\_ebs\_csi\_policy) | Determines whether to attach the EBS CSI IAM policy to the role | `bool` | `false` | no |
143144
| <a name="input_attach_external_dns_policy"></a> [attach\_external\_dns\_policy](#input\_attach\_external\_dns\_policy) | Determines whether to attach the External DNS IAM policy to the role | `bool` | `false` | no |

modules/iam-role-for-service-accounts-eks/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data "aws_iam_policy_document" "this" {
1414
}
1515

1616
condition {
17-
test = "StringEquals"
17+
test = var.assume_role_condition_test
1818
variable = "${replace(statement.value.provider_arn, "/^(.*provider/)/", "")}:sub"
1919
values = [for sa in statement.value.namespace_service_accounts : "system:serviceaccount:${sa}"]
2020
}

modules/iam-role-for-service-accounts-eks/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ variable "max_session_duration" {
6464
default = null
6565
}
6666

67+
variable "assume_role_condition_test" {
68+
description = "Name of the [IAM condition operator](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) to evaluate when assuming the role"
69+
type = string
70+
default = "StringEquals"
71+
}
72+
6773
################################################################################
6874
# Policies
6975
################################################################################

0 commit comments

Comments
 (0)