Skip to content

Commit 26ac3c3

Browse files
committed
fixup! Migrate cluster modules from map(map(string)) to map(object)
1 parent e8e7a16 commit 26ac3c3

13 files changed

Lines changed: 153 additions & 113 deletions

File tree

aws/_modules/eks/node_pool/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ variable "ami_type" {
8888
variable "ami_release_version" {
8989
type = string
9090
description = "AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version"
91-
default = null
9291
}
9392

9493
variable "kubernetes_version" {

aws/_modules/eks/variables.tf

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ variable "metadata_labels" {
1616
variable "availability_zones" {
1717
description = "List of availability_zones for workers."
1818
type = list(string)
19+
default = []
1920
}
2021

2122
variable "vpc_cidr" {
2223
description = "CIDR to use for the VPC."
2324
type = string
25+
default = "10.0.0.0/16"
2426
}
2527

2628
variable "vpc_legacy_node_subnets" {
@@ -32,51 +34,61 @@ variable "vpc_legacy_node_subnets" {
3234
variable "vpc_control_subnet_newbits" {
3335
description = "CIDR newbits to use for the control plane subnets."
3436
type = string
37+
default = "8"
3538
}
3639

3740
variable "vpc_dns_hostnames" {
3841
description = "Enable DNS hostnames in the VPC."
3942
type = bool
43+
default = false
4044
}
4145

4246
variable "vpc_dns_support" {
4347
description = "Enable DNS support in the VPC."
4448
type = bool
49+
default = true
4550
}
4651

4752
variable "vpc_node_subnet_newbits" {
4853
description = "CIDR newbits to use for the node pool subnets."
4954
type = string
55+
default = "4"
5056
}
5157

5258
variable "vpc_node_subnet_number_offset" {
5359
description = "CIDR subnet number offset to use for the node pool subnets."
5460
type = string
61+
default = "1"
5562
}
5663

5764
variable "vpc_subnet_map_public_ip" {
5865
description = "Whether nodes should have public IPs."
5966
type = bool
67+
default = true
6068
}
6169

6270
variable "instance_types" {
6371
description = "Set of AWS instance types to use for nodes."
6472
type = set(string)
73+
default = []
6574
}
6675

6776
variable "desired_capacity" {
6877
description = "Desired number of worker nodes."
6978
type = number
79+
default = 1
7080
}
7181

7282
variable "max_size" {
7383
description = "Maximum number of worker nodes."
7484
type = number
85+
default = 1
7586
}
7687

7788
variable "min_size" {
7889
description = "Minimum number of worker nodes."
7990
type = number
91+
default = 1
8092
}
8193

8294
variable "root_device_encrypted" {
@@ -109,36 +121,41 @@ variable "additional_node_tags" {
109121
variable "aws_auth_map_roles" {
110122
description = "mapRoles entries added to aws-auth configmap"
111123
type = string
124+
default = ""
112125
}
113126

114127
variable "aws_auth_map_users" {
115128
description = "mapUsers entries added to aws-auth configmap"
116129
type = string
130+
default = ""
117131
}
118132

119133
variable "aws_auth_map_accounts" {
120134
description = "mapAccounts entries added to aws-auth configmap"
121135
type = string
136+
default = ""
122137
}
123138

124139
variable "disable_default_ingress" {
125140
type = bool
126141
description = "Whether to disable the default ingress."
142+
default = false
127143
}
128144

129145
variable "enabled_cluster_log_types" {
130146
type = list(string)
131147
description = "List of cluster log types to enable."
148+
default = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
132149
}
133150

134151
variable "disable_openid_connect_provider" {
135152
type = bool
136153
description = "Whether to disable the OpenID connect provider."
154+
default = false
137155
}
138156

139157
variable "cluster_version" {
140158
type = string
141-
default = null
142159
description = "The version of the cluster (defaults to latest available)"
143160
}
144161

@@ -156,31 +173,26 @@ variable "cluster_endpoint_public_access" {
156173

157174
variable "cluster_public_access_cidrs" {
158175
type = list(string)
159-
default = null
160176
description = "List of CIDR blocks which can access the Amazon EKS public API server endpoint. EKS defaults this to a list with 0.0.0.0/0."
161177
}
162178

163179
variable "cluster_service_cidr" {
164180
type = string
165-
default = null
166181
description = "Sets the Service CIDR for the EKS cluster."
167182
}
168183

169184
variable "cluster_encryption_key_arn" {
170185
type = string
171-
default = null
172186
description = "Arn of an AWS KMS symmetric key to be used for encryption of kubernetes resources."
173187
}
174188

175189
variable "worker_ami_type" {
176190
type = string
177-
default = null
178191
description = "AMI type to use for nodes. Defaults to automatically determined based on instance type (AL2023_x86_64_STANDARD, AL2023_ARM_64_STANDARD, AL2023_x86_64_NVIDIA or AL2023_ARM_64_NVIDIA)."
179192
}
180193

181194
variable "worker_ami_release_version" {
182195
type = string
183-
default = null
184196
description = "AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version. A list of release versions can be found in https://github.com/awslabs/amazon-eks-ami/blob/master/CHANGELOG.md"
185197
}
186198

aws/cluster/main.tf

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ module "cluster" {
3030
metadata_fqdn = module.cluster_metadata.fqdn
3131
metadata_labels = module.cluster_metadata.labels
3232

33-
availability_zones = local.cfg["cluster_availability_zones"] != null ? local.cfg["cluster_availability_zones"] : []
33+
availability_zones = local.cfg["cluster_availability_zones"]
3434

35-
vpc_cidr = local.cfg["cluster_vpc_cidr"] != null ? local.cfg["cluster_vpc_cidr"] : "10.0.0.0/16"
36-
vpc_control_subnet_newbits = local.cfg["cluster_vpc_control_subnet_newbits"] != null ? local.cfg["cluster_vpc_control_subnet_newbits"] : local.cfg["cluster_vpc_subnet_newbits"] != null ? local.cfg["cluster_vpc_subnet_newbits"] : "8"
37-
vpc_dns_hostnames = local.cfg["cluster_vpc_dns_hostnames"] != null ? local.cfg["cluster_vpc_dns_hostnames"] : false
38-
vpc_dns_support = local.cfg["cluster_vpc_dns_support"] != null ? local.cfg["cluster_vpc_dns_support"] : true
39-
vpc_node_subnet_newbits = local.cfg["cluster_vpc_node_subnet_newbits"] != null ? local.cfg["cluster_vpc_node_subnet_newbits"] : "4"
40-
vpc_node_subnet_number_offset = local.cfg["cluster_vpc_node_subnet_number_offset"] != null ? local.cfg["cluster_vpc_node_subnet_number_offset"] : "1"
41-
vpc_legacy_node_subnets = local.cfg["cluster_vpc_legacy_node_subnets"] != null ? local.cfg["cluster_vpc_legacy_node_subnets"] : false
42-
vpc_subnet_map_public_ip = local.cfg["cluster_vpc_subnet_map_public_ip"] != null ? local.cfg["cluster_vpc_subnet_map_public_ip"] : true
35+
vpc_cidr = local.cfg["cluster_vpc_cidr"]
36+
vpc_control_subnet_newbits = local.cfg["cluster_vpc_control_subnet_newbits"]
37+
vpc_dns_hostnames = local.cfg["cluster_vpc_dns_hostnames"]
38+
vpc_dns_support = local.cfg["cluster_vpc_dns_support"]
39+
vpc_node_subnet_newbits = local.cfg["cluster_vpc_node_subnet_newbits"]
40+
vpc_node_subnet_number_offset = local.cfg["cluster_vpc_node_subnet_number_offset"]
41+
vpc_legacy_node_subnets = local.cfg["cluster_vpc_legacy_node_subnets"]
42+
vpc_subnet_map_public_ip = local.cfg["cluster_vpc_subnet_map_public_ip"]
4343

4444
instance_types = local.cfg["cluster_instance_types"] != null ? toset(local.cfg["cluster_instance_types"]) : (local.cfg["cluster_instance_type"] != null ? toset([local.cfg["cluster_instance_type"]]) : toset([]))
4545
desired_capacity = local.cfg["cluster_desired_capacity"]
@@ -52,20 +52,20 @@ module "cluster" {
5252
root_device_encrypted = local.cfg["worker_root_device_encrypted"]
5353
root_device_volume_size = local.cfg["worker_root_device_volume_size"]
5454

55-
additional_node_tags = local.cfg["cluster_additional_node_tags"] != null ? local.cfg["cluster_additional_node_tags"] : {}
55+
additional_node_tags = local.cfg["cluster_additional_node_tags"]
5656

57-
aws_auth_map_roles = local.cfg["cluster_aws_auth_map_roles"] != null ? local.cfg["cluster_aws_auth_map_roles"] : ""
58-
aws_auth_map_users = local.cfg["cluster_aws_auth_map_users"] != null ? local.cfg["cluster_aws_auth_map_users"] : ""
59-
aws_auth_map_accounts = local.cfg["cluster_aws_auth_map_accounts"] != null ? local.cfg["cluster_aws_auth_map_accounts"] : ""
57+
aws_auth_map_roles = local.cfg["cluster_aws_auth_map_roles"]
58+
aws_auth_map_users = local.cfg["cluster_aws_auth_map_users"]
59+
aws_auth_map_accounts = local.cfg["cluster_aws_auth_map_accounts"]
6060

61-
disable_default_ingress = local.cfg["disable_default_ingress"] != null ? local.cfg["disable_default_ingress"] : false
61+
disable_default_ingress = local.cfg["disable_default_ingress"]
6262

63-
enabled_cluster_log_types = local.cfg["enabled_cluster_log_types"] != null ? local.cfg["enabled_cluster_log_types"] : ["api", "audit", "authenticator", "controllerManager", "scheduler"]
63+
enabled_cluster_log_types = local.cfg["enabled_cluster_log_types"]
6464

65-
disable_openid_connect_provider = local.cfg["disable_openid_connect_provider"] != null ? local.cfg["disable_openid_connect_provider"] : false
65+
disable_openid_connect_provider = local.cfg["disable_openid_connect_provider"]
6666

67-
cluster_endpoint_private_access = local.cfg["cluster_endpoint_private_access"] != null ? local.cfg["cluster_endpoint_private_access"] : false
68-
cluster_endpoint_public_access = local.cfg["cluster_endpoint_public_access"] != null ? local.cfg["cluster_endpoint_public_access"] : true
67+
cluster_endpoint_private_access = local.cfg["cluster_endpoint_private_access"]
68+
cluster_endpoint_public_access = local.cfg["cluster_endpoint_public_access"]
6969
cluster_public_access_cidrs = local.cfg["cluster_public_access_cidrs"]
7070
cluster_service_cidr = local.cfg["cluster_service_cidr"]
7171

@@ -74,8 +74,5 @@ module "cluster" {
7474
worker_ami_type = local.cfg["worker_ami_type"]
7575
worker_ami_release_version = local.cfg["worker_ami_release_version"]
7676

77-
# cluster module configuration is still map(string)
78-
# once module_variable_optional_attrs isn't experimental anymore
79-
# we can migrate cluster module configuration to map(object(...))
8077
taints = toset([])
8178
}

aws/cluster/node-pool/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module "node_pool" {
4444

4545
kubernetes_version = data.aws_eks_cluster.current.version
4646

47-
disk_size = lookup(local.cfg, "disk_size", null)
47+
disk_size = local.cfg["disk_size"]
4848

49-
metadata_options = lookup(local.cfg, "metadata_options", null)
49+
metadata_options = local.cfg["metadata_options"]
5050

5151
taints = local.cfg["taints"] == null ? toset([]) : local.cfg["taints"]
5252

azurerm/_modules/aks/variables.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,31 @@ variable "legacy_vnet_name" {
3232
variable "vnet_address_space" {
3333
type = list(string)
3434
description = "Address space for the virtual network."
35+
default = ["10.0.0.0/8"]
3536
}
3637

3738
variable "subnet_address_prefixes" {
3839
type = list(string)
3940
description = "Address space for the cluster subnet."
41+
default = ["10.1.0.0/16"]
4042
}
4143

4244
variable "subnet_service_endpoints" {
4345
type = list(string)
4446
description = "List of service endpoints to expose on the subnet."
47+
default = []
4548
}
4649

4750
variable "network_plugin" {
4851
type = string
4952
description = "Network plugin to use. Set to 'azure' for CNI; 'kubenet' for Basic"
53+
default = "kubenet"
5054
}
5155

5256
variable "network_policy" {
5357
type = string
5458
description = "Network policy to use. Set to 'azure' for CNI; 'calico' for Basic"
59+
default = "calico"
5560
}
5661

5762
variable "dns_prefix" {
@@ -63,16 +68,19 @@ variable "dns_prefix" {
6368
variable "service_cidr" {
6469
type = string
6570
description = "CIDR range for kubernetes service."
71+
default = "10.0.0.0/16"
6672
}
6773

6874
variable "dns_service_ip" {
6975
type = string
7076
description = "IP address for the kube-dns service. Must be within service_cidr."
77+
default = "10.0.0.10"
7178
}
7279

7380
variable "pod_cidr" {
7481
type = string
7582
description = "CIDR range for pods."
83+
default = "10.244.0.0/16"
7684
}
7785

7886
variable "max_pods" {
@@ -99,11 +107,13 @@ variable "default_node_pool" {
99107
variable "disable_default_ingress" {
100108
type = bool
101109
description = "Whether to disable the default ingress."
110+
default = false
102111
}
103112

104113
variable "default_ingress_ip_zones" {
105114
type = list(string)
106115
description = "Explicit list of zones for the ingress public IP."
116+
default = []
107117
}
108118

109119
variable "enable_azure_policy_agent" {
@@ -121,7 +131,6 @@ variable "disable_managed_identities" {
121131
variable "user_assigned_identity_id" {
122132
type = string
123133
description = "ID of the UserAssigned identity to use."
124-
default = null
125134
}
126135

127136
variable "sku_tier" {
@@ -156,11 +165,13 @@ variable "availability_zones" {
156165
variable "keda_enabled" {
157166
type = bool
158167
description = "Whether KEDA Autoscaler should be enabled for the cluster."
168+
default = false
159169
}
160170

161171
variable "vertical_pod_autoscaler_enabled" {
162172
type = bool
163173
description = "Whether Vertical Pod Autoscaler should be enabled for the cluster."
174+
default = false
164175
}
165176

166177
variable "upgrade_settings" {

azurerm/cluster/main.tf

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,43 @@ module "cluster" {
3434

3535
metadata_name = module.cluster_metadata.name
3636
metadata_fqdn = module.cluster_metadata.fqdn
37-
metadata_labels = merge(module.cluster_metadata.labels, local.cfg["additional_metadata_labels"])
37+
metadata_labels = merge(module.cluster_metadata.labels, coalesce(local.cfg["additional_metadata_labels"], {}))
3838
metadata_label_namespace = module.cluster_metadata.label_namespace
3939

40-
dns_prefix = local.cfg["dns_prefix"] != null ? local.cfg["dns_prefix"] : "api"
40+
dns_prefix = local.cfg["dns_prefix"]
4141

42-
sku_tier = local.cfg["sku_tier"] != null ? local.cfg["sku_tier"] : "Free"
42+
sku_tier = local.cfg["sku_tier"]
4343

44-
legacy_vnet_name = local.cfg["legacy_vnet_name"] != null ? local.cfg["legacy_vnet_name"] : false
45-
vnet_address_space = local.cfg["vnet_address_space"] != null ? local.cfg["vnet_address_space"] : ["10.0.0.0/8"]
46-
subnet_address_prefixes = local.cfg["subnet_address_prefixes"] != null ? local.cfg["subnet_address_prefixes"] : ["10.1.0.0/16"]
47-
subnet_service_endpoints = local.cfg["subnet_service_endpoints"] != null ? local.cfg["subnet_service_endpoints"] : []
44+
legacy_vnet_name = local.cfg["legacy_vnet_name"]
45+
vnet_address_space = local.cfg["vnet_address_space"]
46+
subnet_address_prefixes = local.cfg["subnet_address_prefixes"]
47+
subnet_service_endpoints = local.cfg["subnet_service_endpoints"]
4848

49-
network_plugin = local.cfg["network_plugin"] != null ? local.cfg["network_plugin"] : "kubenet"
50-
network_policy = local.cfg["network_policy"] != null ? local.cfg["network_policy"] : "calico"
51-
service_cidr = local.cfg["service_cidr"] != null ? local.cfg["service_cidr"] : "10.0.0.0/16"
52-
dns_service_ip = local.cfg["dns_service_ip"] != null ? local.cfg["dns_service_ip"] : "10.0.0.10"
53-
pod_cidr = local.cfg["pod_cidr"] != null ? local.cfg["pod_cidr"] : "10.244.0.0/16"
49+
network_plugin = local.cfg["network_plugin"]
50+
network_policy = local.cfg["network_policy"]
51+
service_cidr = local.cfg["service_cidr"]
52+
dns_service_ip = local.cfg["dns_service_ip"]
53+
pod_cidr = local.cfg["pod_cidr"]
5454
max_pods = local.cfg["max_pods"]
5555

56-
default_node_pool = local.cfg["default_node_pool"] != null ? local.cfg["default_node_pool"] : {}
56+
default_node_pool = local.cfg["default_node_pool"]
5757

58-
disable_default_ingress = local.cfg["disable_default_ingress"] != null ? local.cfg["disable_default_ingress"] : false
59-
default_ingress_ip_zones = local.cfg["default_ingress_ip_zones"] != null ? local.cfg["default_ingress_ip_zones"] : []
58+
disable_default_ingress = local.cfg["disable_default_ingress"]
59+
default_ingress_ip_zones = local.cfg["default_ingress_ip_zones"]
6060

61-
enable_azure_policy_agent = local.cfg["enable_azure_policy_agent"] != null ? local.cfg["enable_azure_policy_agent"] : false
61+
enable_azure_policy_agent = local.cfg["enable_azure_policy_agent"]
6262

63-
disable_managed_identities = local.cfg["disable_managed_identities"] != null ? local.cfg["disable_managed_identities"] : false
63+
disable_managed_identities = local.cfg["disable_managed_identities"]
6464
user_assigned_identity_id = local.cfg["user_assigned_identity_id"]
6565

6666
kubernetes_version = local.cfg["kubernetes_version"]
6767
automatic_channel_upgrade = local.cfg["automatic_channel_upgrade"]
68-
enable_log_analytics = local.cfg["enable_log_analytics"] != null ? local.cfg["enable_log_analytics"] : true
68+
enable_log_analytics = local.cfg["enable_log_analytics"]
6969

7070
availability_zones = local.cfg["availability_zones"]
7171

72-
keda_enabled = local.cfg["keda_enabled"] != null ? local.cfg["keda_enabled"] : false
73-
vertical_pod_autoscaler_enabled = local.cfg["vertical_pod_autoscaler_enabled"] != null ? local.cfg["vertical_pod_autoscaler_enabled"] : false
72+
keda_enabled = local.cfg["keda_enabled"]
73+
vertical_pod_autoscaler_enabled = local.cfg["vertical_pod_autoscaler_enabled"]
7474

75-
upgrade_settings = local.cfg["upgrade_settings"] != null ? local.cfg["upgrade_settings"] : {}
75+
upgrade_settings = local.cfg["upgrade_settings"]
7676
}

0 commit comments

Comments
 (0)