diff --git a/README.md b/README.md index 1d5b5c07be..8fe22d0602 100644 --- a/README.md +++ b/README.md @@ -393,7 +393,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple | [cluster\_additional\_security\_group\_ids](#input\_cluster\_additional\_security\_group\_ids) | List of additional, externally created security group IDs to attach to the cluster control plane | `list(string)` | `[]` | no | | [cluster\_addons](#input\_cluster\_addons) | Map of cluster addon configurations to enable for the cluster. Addon name can be the map keys or set with `name` | `any` | `{}` | no | | [cluster\_addons\_timeouts](#input\_cluster\_addons\_timeouts) | Create, update, and delete timeout configurations for the cluster addons | `map(string)` | `{}` | no | -| [cluster\_compute\_config](#input\_cluster\_compute\_config) | Configuration block for the cluster compute configuration | `any` | `{}` | no | +| [cluster\_compute\_config](#input\_cluster\_compute\_config) | Configuration block for the cluster compute configuration |
object({
enabled = bool
node_pools = optional(list(string), [])
node_role_arn = optional(string)
})
| `null` | no | | [cluster\_enabled\_log\_types](#input\_cluster\_enabled\_log\_types) | A list of the desired control plane logs to enable. For more information, see Amazon EKS Control Plane Logging documentation (https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html) | `list(string)` |
[
"audit",
"api",
"authenticator"
]
| no | | [cluster\_encryption\_config](#input\_cluster\_encryption\_config) | Configuration block with encryption configuration for the cluster. To disable secret encryption, set this value to `{}` | `any` |
{
"resources": [
"secrets"
]
}
| no | | [cluster\_encryption\_policy\_description](#input\_cluster\_encryption\_policy\_description) | Description of the cluster encryption policy created | `string` | `"Cluster encryption policy to allow cluster role to utilize CMK provided"` | no | diff --git a/main.tf b/main.tf index 18933422f5..a0fc9e9029 100644 --- a/main.tf +++ b/main.tf @@ -53,12 +53,12 @@ resource "aws_eks_cluster" "this" { } dynamic "compute_config" { - for_each = length(var.cluster_compute_config) > 0 ? [var.cluster_compute_config] : [] + for_each = var.cluster_compute_config[*] content { enabled = local.auto_mode_enabled - node_pools = local.auto_mode_enabled ? try(compute_config.value.node_pools, []) : null - node_role_arn = local.auto_mode_enabled && length(try(compute_config.value.node_pools, [])) > 0 ? try(compute_config.value.node_role_arn, aws_iam_role.eks_auto[0].arn, null) : null + node_pools = local.auto_mode_enabled ? compute_config.value.node_pools : null + node_role_arn = local.auto_mode_enabled && length(compute_config.value.node_pools) > 0 ? coalesce(compute_config.value.node_role_arn, aws_iam_role.eks_auto[0].arn) : null } } diff --git a/variables.tf b/variables.tf index 855c2133ec..143db090de 100644 --- a/variables.tf +++ b/variables.tf @@ -46,8 +46,12 @@ variable "authentication_mode" { variable "cluster_compute_config" { description = "Configuration block for the cluster compute configuration" - type = any - default = {} + type = object({ + enabled = bool + node_pools = optional(list(string), []) + node_role_arn = optional(string) + }) + default = null } variable "cluster_upgrade_policy" {