mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-16 08:37:18 +01:00
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 <bryantbiggs@gmail.com>
This commit is contained in:
@@ -345,6 +345,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
|
|||||||
| <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 |
|
| <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 |
|
||||||
| <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 |
|
| <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 |
|
||||||
| <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 |
|
| <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 |
|
||||||
|
| <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 |
|
||||||
| <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 |
|
| <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 |
|
||||||
| <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 |
|
| <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 |
|
||||||
| <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 |
|
| <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 |
|
||||||
|
|||||||
13
main.tf
13
main.tf
@@ -220,19 +220,26 @@ resource "aws_security_group_rule" "cluster" {
|
|||||||
# Note - this is different from EKS identity provider
|
# Note - this is different from EKS identity provider
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
locals {
|
||||||
|
# Not available on outposts
|
||||||
|
create_oidc_provider = local.create && var.enable_irsa && !local.create_outposts_local_cluster
|
||||||
|
|
||||||
|
oidc_root_ca_thumbprint = local.create_oidc_provider && var.include_oidc_root_ca_thumbprint ? [data.tls_certificate.this[0].certificates[0].sha1_fingerprint] : []
|
||||||
|
}
|
||||||
|
|
||||||
data "tls_certificate" "this" {
|
data "tls_certificate" "this" {
|
||||||
# Not available on outposts
|
# Not available on outposts
|
||||||
count = local.create && var.enable_irsa && !local.create_outposts_local_cluster ? 1 : 0
|
count = local.create_oidc_provider && var.include_oidc_root_ca_thumbprint ? 1 : 0
|
||||||
|
|
||||||
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
|
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_openid_connect_provider" "oidc_provider" {
|
resource "aws_iam_openid_connect_provider" "oidc_provider" {
|
||||||
# Not available on outposts
|
# Not available on outposts
|
||||||
count = local.create && var.enable_irsa && !local.create_outposts_local_cluster ? 1 : 0
|
count = local.create_oidc_provider ? 1 : 0
|
||||||
|
|
||||||
client_id_list = distinct(compact(concat(["sts.${local.dns_suffix}"], var.openid_connect_audiences)))
|
client_id_list = distinct(compact(concat(["sts.${local.dns_suffix}"], var.openid_connect_audiences)))
|
||||||
thumbprint_list = concat([data.tls_certificate.this[0].certificates[0].sha1_fingerprint], var.custom_oidc_thumbprints)
|
thumbprint_list = concat(local.oidc_root_ca_thumbprint, var.custom_oidc_thumbprints)
|
||||||
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
|
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
|
||||||
|
|
||||||
tags = merge(
|
tags = merge(
|
||||||
|
|||||||
@@ -358,6 +358,12 @@ variable "openid_connect_audiences" {
|
|||||||
default = []
|
default = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "include_oidc_root_ca_thumbprint" {
|
||||||
|
description = "Determines whether to include the root CA thumbprint in the OpenID Connect (OIDC) identity provider's server certificate(s)"
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
variable "custom_oidc_thumbprints" {
|
variable "custom_oidc_thumbprints" {
|
||||||
description = "Additional list of server certificate thumbprints for the OpenID Connect (OIDC) identity provider's server certificate(s)"
|
description = "Additional list of server certificate thumbprints for the OpenID Connect (OIDC) identity provider's server certificate(s)"
|
||||||
type = list(string)
|
type = list(string)
|
||||||
|
|||||||
Reference in New Issue
Block a user