Skip to content

Commit 9c16be0

Browse files
authored
fix: Correct variable types to improve dynamic check correctness (#2133)
1 parent a7e21f8 commit 9c16be0

File tree

7 files changed

+103
-103
lines changed

7 files changed

+103
-103
lines changed

modules/eks-managed-node-group/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module "eks_managed_node_group" {
9191
| <a name="input_ami_type"></a> [ami\_type](#input\_ami\_type) | Type of Amazon Machine Image (AMI) associated with the EKS Node Group. Valid values are `AL2_x86_64`, `AL2_x86_64_GPU`, `AL2_ARM_64`, `CUSTOM`, `BOTTLEROCKET_ARM_64`, `BOTTLEROCKET_x86_64` | `string` | `null` | no |
9292
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI | `any` | `{}` | no |
9393
| <a name="input_bootstrap_extra_args"></a> [bootstrap\_extra\_args](#input\_bootstrap\_extra\_args) | Additional arguments passed to the bootstrap script. When `platform` = `bottlerocket`; these are additional [settings](https://github.com/bottlerocket-os/bottlerocket#settings) that are provided to the Bottlerocket user data | `string` | `""` | no |
94-
| <a name="input_capacity_reservation_specification"></a> [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Targeting for EC2 capacity reservations | `any` | `null` | no |
94+
| <a name="input_capacity_reservation_specification"></a> [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Targeting for EC2 capacity reservations | `any` | `{}` | no |
9595
| <a name="input_capacity_type"></a> [capacity\_type](#input\_capacity\_type) | Type of capacity associated with the EKS Node Group. Valid values: `ON_DEMAND`, `SPOT` | `string` | `"ON_DEMAND"` | no |
9696
| <a name="input_cluster_auth_base64"></a> [cluster\_auth\_base64](#input\_cluster\_auth\_base64) | Base64 encoded CA of associated EKS cluster | `string` | `""` | no |
9797
| <a name="input_cluster_endpoint"></a> [cluster\_endpoint](#input\_cluster\_endpoint) | Endpoint of associated EKS cluster | `string` | `""` | no |
@@ -101,21 +101,21 @@ module "eks_managed_node_group" {
101101
| <a name="input_cluster_security_group_id"></a> [cluster\_security\_group\_id](#input\_cluster\_security\_group\_id) | Cluster control plane security group ID | `string` | `null` | no |
102102
| <a name="input_cluster_service_ipv4_cidr"></a> [cluster\_service\_ipv4\_cidr](#input\_cluster\_service\_ipv4\_cidr) | The CIDR block to assign Kubernetes service IP addresses from. If you don't specify a block, Kubernetes assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks | `string` | `null` | no |
103103
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes version. Defaults to EKS Cluster Kubernetes version | `string` | `null` | no |
104-
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `null` | no |
104+
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `{}` | no |
105105
| <a name="input_create"></a> [create](#input\_create) | Determines whether to create EKS managed node group or not | `bool` | `true` | no |
106106
| <a name="input_create_iam_role"></a> [create\_iam\_role](#input\_create\_iam\_role) | Determines whether an IAM role is created or to use an existing IAM role | `bool` | `true` | no |
107107
| <a name="input_create_launch_template"></a> [create\_launch\_template](#input\_create\_launch\_template) | Determines whether to create a launch template or not. If set to `false`, EKS will use its own default launch template | `bool` | `true` | no |
108108
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines whether to create a security group | `bool` | `true` | no |
109-
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instance | `map(string)` | `null` | no |
109+
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instance | `map(string)` | `{}` | no |
110110
| <a name="input_desired_size"></a> [desired\_size](#input\_desired\_size) | Desired number of instances/nodes | `number` | `1` | no |
111111
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 instance termination protection | `bool` | `null` | no |
112112
| <a name="input_disk_size"></a> [disk\_size](#input\_disk\_size) | Disk size in GiB for nodes. Defaults to `20` | `number` | `null` | no |
113113
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance(s) will be EBS-optimized | `bool` | `null` | no |
114-
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `map(string)` | `null` | no |
115-
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `null` | no |
114+
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `map(string)` | `{}` | no |
115+
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
116116
| <a name="input_enable_bootstrap_user_data"></a> [enable\_bootstrap\_user\_data](#input\_enable\_bootstrap\_user\_data) | Determines whether the bootstrap configurations are populated within the user data template | `bool` | `false` | no |
117117
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
118-
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `null` | no |
118+
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
119119
| <a name="input_force_update_version"></a> [force\_update\_version](#input\_force\_update\_version) | Force version update if existing pods are unable to be drained due to a pod disruption budget issue | `bool` | `null` | no |
120120
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `list(string)` | `[]` | no |
121121
| <a name="input_iam_role_arn"></a> [iam\_role\_arn](#input\_iam\_role\_arn) | Existing IAM role ARN for the node group. Required if `create_iam_role` is set to `false` | `string` | `null` | no |
@@ -126,7 +126,7 @@ module "eks_managed_node_group" {
126126
| <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 |
127127
| <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 |
128128
| <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 |
129-
| <a name="input_instance_market_options"></a> [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instance | `any` | `null` | no |
129+
| <a name="input_instance_market_options"></a> [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instance | `any` | `{}` | no |
130130
| <a name="input_instance_types"></a> [instance\_types](#input\_instance\_types) | Set of instance types associated with the EKS Node Group. Defaults to `["t3.medium"]` | `list(string)` | `null` | no |
131131
| <a name="input_kernel_id"></a> [kernel\_id](#input\_kernel\_id) | The kernel ID | `string` | `null` | no |
132132
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The key name that should be used for the instance(s) | `string` | `null` | no |
@@ -137,13 +137,13 @@ module "eks_managed_node_group" {
137137
| <a name="input_launch_template_tags"></a> [launch\_template\_tags](#input\_launch\_template\_tags) | A map of additional tags to add to the tag\_specifications of launch template created | `map(string)` | `{}` | no |
138138
| <a name="input_launch_template_use_name_prefix"></a> [launch\_template\_use\_name\_prefix](#input\_launch\_template\_use\_name\_prefix) | Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix | `bool` | `true` | no |
139139
| <a name="input_launch_template_version"></a> [launch\_template\_version](#input\_launch\_template\_version) | Launch template version number. The default is `$Default` | `string` | `null` | no |
140-
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A list of license specifications to associate with | `map(string)` | `null` | no |
140+
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A list of license specifications to associate with | `map(string)` | `{}` | no |
141141
| <a name="input_max_size"></a> [max\_size](#input\_max\_size) | Maximum number of instances/nodes | `number` | `3` | no |
142142
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options for the instance | `map(string)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required"<br>}</pre> | no |
143143
| <a name="input_min_size"></a> [min\_size](#input\_min\_size) | Minimum number of instances/nodes | `number` | `0` | no |
144144
| <a name="input_name"></a> [name](#input\_name) | Name of the EKS managed node group | `string` | `""` | no |
145145
| <a name="input_network_interfaces"></a> [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time | `list(any)` | `[]` | no |
146-
| <a name="input_placement"></a> [placement](#input\_placement) | The placement of the instance | `map(string)` | `null` | no |
146+
| <a name="input_placement"></a> [placement](#input\_placement) | The placement of the instance | `map(string)` | `{}` | no |
147147
| <a name="input_platform"></a> [platform](#input\_platform) | Identifies if the OS platform is `bottlerocket` or `linux` based; `windows` is not supported | `string` | `"linux"` | no |
148148
| <a name="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data) | User data that is appended to the user data script after of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
149149
| <a name="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data) | User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |

modules/eks-managed-node-group/main.tf

+11-11
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ resource "aws_launch_template" "this" {
9191
}
9292

9393
dynamic "capacity_reservation_specification" {
94-
for_each = var.capacity_reservation_specification != null ? [var.capacity_reservation_specification] : []
94+
for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : []
9595
content {
9696
capacity_reservation_preference = lookup(capacity_reservation_specification.value, "capacity_reservation_preference", null)
9797

@@ -105,36 +105,36 @@ resource "aws_launch_template" "this" {
105105
}
106106

107107
dynamic "cpu_options" {
108-
for_each = var.cpu_options != null ? [var.cpu_options] : []
108+
for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : []
109109
content {
110110
core_count = cpu_options.value.core_count
111111
threads_per_core = cpu_options.value.threads_per_core
112112
}
113113
}
114114

115115
dynamic "credit_specification" {
116-
for_each = var.credit_specification != null ? [var.credit_specification] : []
116+
for_each = length(var.credit_specification) > 0 ? [var.credit_specification] : []
117117
content {
118118
cpu_credits = credit_specification.value.cpu_credits
119119
}
120120
}
121121

122122
dynamic "elastic_gpu_specifications" {
123-
for_each = var.elastic_gpu_specifications != null ? [var.elastic_gpu_specifications] : []
123+
for_each = length(var.elastic_gpu_specifications) > 0 ? [var.elastic_gpu_specifications] : []
124124
content {
125125
type = elastic_gpu_specifications.value.type
126126
}
127127
}
128128

129129
dynamic "elastic_inference_accelerator" {
130-
for_each = var.elastic_inference_accelerator != null ? [var.elastic_inference_accelerator] : []
130+
for_each = length(var.elastic_inference_accelerator) > 0 ? [var.elastic_inference_accelerator] : []
131131
content {
132132
type = elastic_inference_accelerator.value.type
133133
}
134134
}
135135

136136
dynamic "enclave_options" {
137-
for_each = var.enclave_options != null ? [var.enclave_options] : []
137+
for_each = length(var.enclave_options) > 0 ? [var.enclave_options] : []
138138
content {
139139
enabled = enclave_options.value.enabled
140140
}
@@ -160,12 +160,12 @@ resource "aws_launch_template" "this" {
160160
# }
161161

162162
dynamic "instance_market_options" {
163-
for_each = var.instance_market_options != null ? [var.instance_market_options] : []
163+
for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : []
164164
content {
165165
market_type = instance_market_options.value.market_type
166166

167167
dynamic "spot_options" {
168-
for_each = lookup(instance_market_options.value, "spot_options", null) != null ? [instance_market_options.value.spot_options] : []
168+
for_each = length(lookup(instance_market_options.value, "spot_options", {})) > 0 ? [instance_market_options.value.spot_options] : []
169169
content {
170170
block_duration_minutes = lookup(spot_options.value, "block_duration_minutes", null)
171171
instance_interruption_behavior = lookup(spot_options.value, "instance_interruption_behavior", null)
@@ -178,14 +178,14 @@ resource "aws_launch_template" "this" {
178178
}
179179

180180
dynamic "license_specification" {
181-
for_each = var.license_specifications != null ? [var.license_specifications] : []
181+
for_each = length(var.license_specifications) > 0 ? [var.license_specifications] : []
182182
content {
183183
license_configuration_arn = license_specifications.value.license_configuration_arn
184184
}
185185
}
186186

187187
dynamic "metadata_options" {
188-
for_each = var.metadata_options != null ? [var.metadata_options] : []
188+
for_each = length(var.metadata_options) > 0 ? [var.metadata_options] : []
189189
content {
190190
http_endpoint = lookup(metadata_options.value, "http_endpoint", null)
191191
http_tokens = lookup(metadata_options.value, "http_tokens", null)
@@ -225,7 +225,7 @@ resource "aws_launch_template" "this" {
225225
}
226226

227227
dynamic "placement" {
228-
for_each = var.placement != null ? [var.placement] : []
228+
for_each = length(var.placement) > 0 ? [var.placement] : []
229229
content {
230230
affinity = lookup(placement.value, "affinity", null)
231231
availability_zone = lookup(placement.value, "availability_zone", null)

modules/eks-managed-node-group/variables.tf

+9-9
Original file line numberDiff line numberDiff line change
@@ -171,49 +171,49 @@ variable "block_device_mappings" {
171171
variable "capacity_reservation_specification" {
172172
description = "Targeting for EC2 capacity reservations"
173173
type = any
174-
default = null
174+
default = {}
175175
}
176176

177177
variable "cpu_options" {
178178
description = "The CPU options for the instance"
179179
type = map(string)
180-
default = null
180+
default = {}
181181
}
182182

183183
variable "credit_specification" {
184184
description = "Customize the credit specification of the instance"
185185
type = map(string)
186-
default = null
186+
default = {}
187187
}
188188

189189
variable "elastic_gpu_specifications" {
190190
description = "The elastic GPU to attach to the instance"
191191
type = map(string)
192-
default = null
192+
default = {}
193193
}
194194

195195
variable "elastic_inference_accelerator" {
196196
description = "Configuration block containing an Elastic Inference Accelerator to attach to the instance"
197197
type = map(string)
198-
default = null
198+
default = {}
199199
}
200200

201201
variable "enclave_options" {
202202
description = "Enable Nitro Enclaves on launched instances"
203203
type = map(string)
204-
default = null
204+
default = {}
205205
}
206206

207207
variable "instance_market_options" {
208208
description = "The market (purchasing) option for the instance"
209209
type = any
210-
default = null
210+
default = {}
211211
}
212212

213213
variable "license_specifications" {
214214
description = "A list of license specifications to associate with"
215215
type = map(string)
216-
default = null
216+
default = {}
217217
}
218218

219219
variable "metadata_options" {
@@ -241,7 +241,7 @@ variable "network_interfaces" {
241241
variable "placement" {
242242
description = "The placement of the instance"
243243
type = map(string)
244-
default = null
244+
default = {}
245245
}
246246

247247
variable "launch_template_tags" {

0 commit comments

Comments
 (0)