Skip to content

Commit 091c680

Browse files
feat: Allow OIDC root CA thumbprint to be included/excluded (#2778)
* fix: Allow OIDC root CA thumbprint to be included/excluded * chore: Consolidate conditional logic within local conditional --------- Co-authored-by: Bryant Biggs <[email protected]>
1 parent f0e2e8b commit 091c680

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
345345
| <a name="input_iam_role_permissions_boundary"></a> [iam\_role\_permissions\_boundary](#input\_iam\_role\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the IAM role | `string` | `null` | no |
346346
| <a name="input_iam_role_tags"></a> [iam\_role\_tags](#input\_iam\_role\_tags) | A map of additional tags to add to the IAM role created | `map(string)` | `{}` | no |
347347
| <a name="input_iam_role_use_name_prefix"></a> [iam\_role\_use\_name\_prefix](#input\_iam\_role\_use\_name\_prefix) | Determines whether the IAM role name (`iam_role_name`) is used as a prefix | `bool` | `true` | no |
348+
| <a name="input_include_oidc_root_ca_thumbprint"></a> [include\_oidc\_root\_ca\_thumbprint](#input\_include\_oidc\_root\_ca\_thumbprint) | Determines whether to include the root CA thumbprint in the OpenID Connect (OIDC) identity provider's server certificate(s) | `bool` | `true` | no |
348349
| <a name="input_kms_key_administrators"></a> [kms\_key\_administrators](#input\_kms\_key\_administrators) | A list of IAM ARNs for [key administrators](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-default-allow-administrators). If no value is provided, the current caller identity is used to ensure at least one key admin is available | `list(string)` | `[]` | no |
349350
| <a name="input_kms_key_aliases"></a> [kms\_key\_aliases](#input\_kms\_key\_aliases) | A list of aliases to create. Note - due to the use of `toset()`, values must be static strings and not computed values | `list(string)` | `[]` | no |
350351
| <a name="input_kms_key_deletion_window_in_days"></a> [kms\_key\_deletion\_window\_in\_days](#input\_kms\_key\_deletion\_window\_in\_days) | The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key. If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30` | `number` | `null` | no |

main.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,26 @@ resource "aws_security_group_rule" "cluster" {
220220
# Note - this is different from EKS identity provider
221221
################################################################################
222222

223+
locals {
224+
# Not available on outposts
225+
create_oidc_provider = local.create && var.enable_irsa && !local.create_outposts_local_cluster
226+
227+
oidc_root_ca_thumbprint = local.create_oidc_provider && var.include_oidc_root_ca_thumbprint ? [data.tls_certificate.this[0].certificates[0].sha1_fingerprint] : []
228+
}
229+
223230
data "tls_certificate" "this" {
224231
# Not available on outposts
225-
count = local.create && var.enable_irsa && !local.create_outposts_local_cluster ? 1 : 0
232+
count = local.create_oidc_provider && var.include_oidc_root_ca_thumbprint ? 1 : 0
226233

227234
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
228235
}
229236

230237
resource "aws_iam_openid_connect_provider" "oidc_provider" {
231238
# Not available on outposts
232-
count = local.create && var.enable_irsa && !local.create_outposts_local_cluster ? 1 : 0
239+
count = local.create_oidc_provider ? 1 : 0
233240

234241
client_id_list = distinct(compact(concat(["sts.${local.dns_suffix}"], var.openid_connect_audiences)))
235-
thumbprint_list = concat([data.tls_certificate.this[0].certificates[0].sha1_fingerprint], var.custom_oidc_thumbprints)
242+
thumbprint_list = concat(local.oidc_root_ca_thumbprint, var.custom_oidc_thumbprints)
236243
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
237244

238245
tags = merge(

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ variable "openid_connect_audiences" {
358358
default = []
359359
}
360360

361+
variable "include_oidc_root_ca_thumbprint" {
362+
description = "Determines whether to include the root CA thumbprint in the OpenID Connect (OIDC) identity provider's server certificate(s)"
363+
type = bool
364+
default = true
365+
}
366+
361367
variable "custom_oidc_thumbprints" {
362368
description = "Additional list of server certificate thumbprints for the OpenID Connect (OIDC) identity provider's server certificate(s)"
363369
type = list(string)

0 commit comments

Comments
 (0)