Description
Description
There is one logic error around the cluster_config_mode
, and another error around the API interaction.
The logic error is that if a user assigns a null
value to cluster_config_mode
, then the length()
function throws an error, here:
Line 56 in 1bfc10a
╷
│ Error: Invalid function argument
│
│ on .terraform/modules/eks.cluster/main.tf line 56, in resource "aws_eks_cluster" "this":
│ 56: for_each = length(var.cluster_compute_config) > 0 ? [var.cluster_compute_config] : []
│ ├────────────────
│ │ while calling length(value)
│ │ var.cluster_compute_config is null
│
│ Invalid value for "value" parameter: argument must not be null.
╵
Since the default value is already an empty map, that error is most easily fixed by adding nullable = false
to the variable definition.
The second error, around the API interaction, is that if you only set cluster_config_mode.enabled = false
, then the cluster will plan fine, but then fail to create with an error reported by the API during the apply:
│ Error: creating EKS Cluster (test-minimum-inputs-kuneic): operation error EKS: CreateCluster, https response error StatusCode: 400, RequestID: 573c664d-68c6-463c-b117-ba12722ebe96, InvalidParameterException: For EKS Auto Mode, please ensure that all required configs, including computeConfig, kubernetesNetworkConfig, and blockStorage are all either fully enabled or fully disabled.
In one sense, I think the API is doing the wrong thing, since we're disabling auto mode and the module already empties all the other mentioned configs when disabling the compute config. But probably the easiest way to resolve the problem is to change the condition on the dynamic block to just be local.auto_mode_enabled
, instead of testing the length()
of the input...
Note that this was previously reported, but the issue was closed without resolution due to lack of details, #3268. Hopefully I've provided enough to pursue/accept a fix.
I'll have a PR ready shortly to resolve this report...
- ✋ I have searched the open/closed issues and my issue is not listed.
Versions
-
Module version [Required]: 20.33.1
-
Terraform version: 1.10.5
- Provider version(s):
+ provider registry.terraform.io/hashicorp/aws v5.87.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.5
+ provider registry.terraform.io/hashicorp/helm v2.17.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.35.1
+ provider registry.terraform.io/hashicorp/null v3.2.3
+ provider registry.terraform.io/hashicorp/random v3.6.3
+ provider registry.terraform.io/hashicorp/time v0.12.1
+ provider registry.terraform.io/hashicorp/tls v4.0.6
Reproduction Code [Required]
cluster_compute_config = null
cluster_compute_config = {
enabled = false
}
Expected behavior
-
Expected to be able to pass a
null
value tocluster_compute_config
to get the default value. -
Expected to be able to disable Auto Mode by setting
cluster_compute_config.enabled = false
.
Actual behavior
Both scenarios fail, for reasons detailed above.