Skip to content

Commit cc6919d

Browse files
tculpTyler Culp
andauthored
feat: Allow enable/disable of EKS pod identity for the Karpenter controller (#2902)
* Made EKS pod identities for the controller role toggleable * Switched the variable to the singular form --------- Co-authored-by: Tyler Culp <[email protected]>
1 parent f6992b1 commit cc6919d

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

modules/karpenter/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ No modules.
135135
| <a name="input_create_iam_role"></a> [create\_iam\_role](#input\_create\_iam\_role) | Determines whether an IAM role is created | `bool` | `true` | no |
136136
| <a name="input_create_instance_profile"></a> [create\_instance\_profile](#input\_create\_instance\_profile) | Whether to create an IAM instance profile | `bool` | `false` | no |
137137
| <a name="input_create_node_iam_role"></a> [create\_node\_iam\_role](#input\_create\_node\_iam\_role) | Determines whether an IAM role is created or to use an existing IAM role | `bool` | `true` | no |
138-
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to enable support IAM role for service account | `bool` | `false` | no |
138+
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to enable support for IAM role for service accounts | `bool` | `false` | no |
139+
| <a name="input_enable_pod_identity"></a> [enable\_pod\_identity](#input\_enable\_pod\_identity) | Determines whether to enable support for EKS pod identity | `bool` | `true` | no |
139140
| <a name="input_enable_spot_termination"></a> [enable\_spot\_termination](#input\_enable\_spot\_termination) | Determines whether to enable native spot termination handling | `bool` | `true` | no |
140141
| <a name="input_iam_policy_description"></a> [iam\_policy\_description](#input\_iam\_policy\_description) | IAM policy description | `string` | `"Karpenter controller IAM policy"` | no |
141142
| <a name="input_iam_policy_name"></a> [iam\_policy\_name](#input\_iam\_policy\_name) | Name of the IAM policy | `string` | `"KarpenterController"` | no |

modules/karpenter/main.tf

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ data "aws_iam_policy_document" "controller_assume_role" {
2222
count = local.create_iam_role ? 1 : 0
2323

2424
# Pod Identity
25-
statement {
26-
actions = [
27-
"sts:AssumeRole",
28-
"sts:TagSession",
29-
]
25+
dynamic "statement" {
26+
for_each = var.enable_pod_identity ? [1] : []
3027

31-
principals {
32-
type = "Service"
33-
identifiers = ["pods.eks.amazonaws.com"]
28+
content {
29+
actions = [
30+
"sts:AssumeRole",
31+
"sts:TagSession",
32+
]
33+
34+
principals {
35+
type = "Service"
36+
identifiers = ["pods.eks.amazonaws.com"]
37+
}
3438
}
3539
}
3640

modules/karpenter/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,18 @@ variable "ami_id_ssm_parameter_arns" {
104104
default = []
105105
}
106106

107+
variable "enable_pod_identity" {
108+
description = "Determines whether to enable support for EKS pod identity"
109+
type = bool
110+
default = true
111+
}
112+
107113
################################################################################
108114
# IAM Role for Service Account (IRSA)
109115
################################################################################
110116

111117
variable "enable_irsa" {
112-
description = "Determines whether to enable support IAM role for service account"
118+
description = "Determines whether to enable support for IAM role for service accounts"
113119
type = bool
114120
default = false
115121
}

0 commit comments

Comments
 (0)