Skip to content

Commit 4f47d6a

Browse files
authored
fix: Regex for network, subnetwork, CIDR block and Workload Pool in standard and autopilot cluster (#2479)
1 parent c4869a4 commit 4f47d6a

File tree

9 files changed

+62
-8
lines changed

9 files changed

+62
-8
lines changed

modules/gke-autopilot-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For a module with a complete configuration of a Google Cloud Platform Kubernetes
4141
| logging\_config | The GKE components exposing logs. Supported values include: SYSTEM\_COMPONENTS, APISERVER, CONTROLLER\_MANAGER, SCHEDULER, and WORKLOADS. | <pre>object({<br> enable_components = optional(list(string))<br> })</pre> | `null` | no |
4242
| maintenance\_policy | The maintenance policy to use for the cluster. | <pre>object({<br> daily_maintenance_window = optional(object({<br> start_time = optional(string)<br> }))<br> recurring_window = optional(object({<br> start_time = optional(string)<br> end_time = optional(string)<br> recurrence = optional(string)<br> }))<br> maintenance_exclusion = optional(list(object({<br> exclusion_name = optional(string)<br> start_time = optional(string)<br> end_time = optional(string)<br> exclusion_options = optional(object({<br> scope = optional(string)<br> }))<br> })))<br> })</pre> | <pre>{<br> "daily_maintenance_window": {<br> "start_time": "05:00"<br> }<br>}</pre> | no |
4343
| master\_auth | The authentication information for accessing the Kubernetes master. | <pre>object({<br> client_certificate_config = optional(object({<br> issue_client_certificate = optional(bool)<br> }))<br> })</pre> | `null` | no |
44-
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. | <pre>object({<br> cidr_blocks = list(object({<br> display_name = string<br> cidr_block = string<br> }))<br> gcp_public_cidrs_access_enabled = optional(bool)<br> private_endpoint_enforcement_enabled = optional(bool)<br> })</pre> | n/a | yes |
44+
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation) | <pre>object({<br> cidr_blocks = list(object({<br> display_name = string<br> cidr_block = string<br> }))<br> gcp_public_cidrs_access_enabled = optional(bool)<br> private_endpoint_enforcement_enabled = optional(bool)<br> })</pre> | n/a | yes |
4545
| mesh\_certificates | Configuration for the provisioning of managed mesh certificates. | <pre>object({<br> enable_certificates = optional(bool)<br> })</pre> | `null` | no |
4646
| min\_master\_version | The minimum version of the master. GKE will auto-update the master to new versions, so this does not guarantee the master version--use the read-only master\_version field to obtain a current version. If unset, the server's default version will be used. | `string` | `null` | no |
4747
| monitoring\_config | (Optional) The GKE components exposing metrics. Supported values include: SYSTEM\_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER\_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM and JOBSET. | <pre>object({<br> enable_components = optional(list(string))<br> })</pre> | `null` | no |

modules/gke-autopilot-cluster/metadata.display.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ spec:
256256
master_authorized_networks_config:
257257
name: master_authorized_networks_config
258258
title: Master Authorized Networks Config
259+
properties:
260+
cidr_blocks:
261+
name: cidr_blocks
262+
title: Cidr Blocks
263+
properties:
264+
cidr_block:
265+
name: cidr_block
266+
title: Cidr Block
267+
regexValidation: ^((((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[12]?[0-9]))|((((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\/(12[0-8]|1[01][0-9]|[1-9]?[0-9]))))$
268+
validation: Enter the valid CIDR notation.
259269
mesh_certificates:
260270
name: mesh_certificates
261271
title: Mesh Certificates
@@ -306,6 +316,11 @@ spec:
306316
network:
307317
name: network
308318
title: Network
319+
regexValidation: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$
320+
validation: Network name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
321+
altDefaults:
322+
- type: ALTERNATE_TYPE_DC
323+
value: default
309324
node_locations:
310325
name: node_locations
311326
title: Node Locations
@@ -456,6 +471,11 @@ spec:
456471
subnetwork:
457472
name: subnetwork
458473
title: Subnetwork
474+
regexValidation: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$
475+
validation: Subnetwork name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
476+
altDefaults:
477+
- type: ALTERNATE_TYPE_DC
478+
value: default
459479
timeouts:
460480
name: timeouts
461481
title: Timeouts
@@ -468,6 +488,12 @@ spec:
468488
workload_identity_config:
469489
name: workload_identity_config
470490
title: Workload Identity Config
491+
properties:
492+
workload_pool:
493+
name: workload_pool
494+
title: Workload Pool
495+
regexValidation: ^[a-z]([-a-z0-9]{4,28}[a-z0-9])\.svc\.id\.goog$
496+
validation: Workload pool must be in the format <project_id>.svc.id.goog. project_id must be between 6 and 30 characters can have lowercase letters, digits, or hyphens. It must start with a lowercase letter and end with a letter or number.
471497
runtime:
472498
outputs:
473499
cluster_id:

modules/gke-autopilot-cluster/metadata.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ spec:
274274
}))
275275
})
276276
- name: master_authorized_networks_config
277-
description: The desired configuration options for master authorized networks.
277+
description: The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)
278278
varType: |-
279279
object({
280280
cidr_blocks = list(object({
@@ -571,9 +571,9 @@ spec:
571571
roles:
572572
- level: Project
573573
roles:
574-
- roles/iam.serviceAccountUser
575574
- roles/compute.admin
576575
- roles/container.admin
576+
- roles/iam.serviceAccountUser
577577
services:
578578
- compute.googleapis.com
579579
- container.googleapis.com

modules/gke-autopilot-cluster/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ variable "master_auth" {
201201
}
202202

203203
variable "master_authorized_networks_config" {
204-
description = "The desired configuration options for master authorized networks."
204+
description = "The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)"
205205
type = object({
206206
cidr_blocks = list(object({
207207
display_name = string

modules/gke-node-pool/metadata.display.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ spec:
6363
name: name
6464
title: Name
6565
level: 1
66+
regexValidation: ^[a-z]([a-z0-9-]{0,38}[a-z0-9])?$
67+
validation: Node pool name must start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
6668
name_prefix:
6769
name: name_prefix
6870
title: Name Prefix

modules/gke-standard-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ For a module with a complete configuration of a Google Cloud Platform Kubernetes
4848
| logging\_service | The logging service that the cluster should write logs to. Available options include `logging.googleapis.com`, `logging.googleapis.com/kubernetes`, and `none`. | `string` | `null` | no |
4949
| maintenance\_policy | The maintenance policy to use for the cluster. | <pre>object({<br> daily_maintenance_window = optional(object({<br> start_time = optional(string)<br> }))<br> recurring_window = optional(object({<br> start_time = optional(string)<br> end_time = optional(string)<br> recurrence = optional(string)<br> }))<br> maintenance_exclusion = optional(list(object({<br> exclusion_name = optional(string)<br> start_time = optional(string)<br> end_time = optional(string)<br> exclusion_options = optional(object({<br> scope = optional(string)<br> }))<br> })))<br> })</pre> | `null` | no |
5050
| master\_auth | The authentication information for accessing the Kubernetes master. | <pre>object({<br> client_certificate_config = optional(object({<br> issue_client_certificate = optional(bool)<br> }))<br> })</pre> | `null` | no |
51-
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. | <pre>object({<br> cidr_blocks = list(object({<br> display_name = string<br> cidr_block = string<br> }))<br> gcp_public_cidrs_access_enabled = optional(bool)<br> private_endpoint_enforcement_enabled = optional(bool)<br> })</pre> | n/a | yes |
51+
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation) | <pre>object({<br> cidr_blocks = list(object({<br> display_name = string<br> cidr_block = string<br> }))<br> gcp_public_cidrs_access_enabled = optional(bool)<br> private_endpoint_enforcement_enabled = optional(bool)<br> })</pre> | n/a | yes |
5252
| mesh\_certificates | Configuration for the provisioning of managed mesh certificates. | <pre>object({<br> enable_certificates = optional(bool)<br> })</pre> | `null` | no |
5353
| min\_master\_version | The minimum version of the master. GKE will auto-update the master to new versions, so this does not guarantee the master version--use the read-only master\_version field to obtain a current version. If unset, the server's default version will be used. | `string` | `null` | no |
5454
| monitoring\_config | Monitoring configuration for the cluster. | <pre>object({<br> enable_components = optional(list(string))<br> })</pre> | `null` | no |

modules/gke-standard-cluster/metadata.display.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ spec:
375375
master_authorized_networks_config:
376376
name: master_authorized_networks_config
377377
title: Master Authorized Networks Config
378+
properties:
379+
cidr_blocks:
380+
name: cidr_blocks
381+
title: Cidr Blocks
382+
properties:
383+
cidr_block:
384+
name: cidr_block
385+
title: Cidr Block
386+
regexValidation: ^((((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[12]?[0-9]))|((((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\/(12[0-8]|1[01][0-9]|[1-9]?[0-9]))))$
387+
validation: Enter the valid CIDR notation.
378388
mesh_certificates:
379389
name: mesh_certificates
380390
title: Mesh Certificates
@@ -406,6 +416,11 @@ spec:
406416
network:
407417
name: network
408418
title: Network
419+
regexValidation: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$
420+
validation: Network name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
421+
altDefaults:
422+
- type: ALTERNATE_TYPE_DC
423+
value: default
409424
network_policy:
410425
name: network_policy
411426
title: Network Policy
@@ -977,6 +992,11 @@ spec:
977992
subnetwork:
978993
name: subnetwork
979994
title: Subnetwork
995+
regexValidation: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$
996+
validation: Subnetwork name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
997+
altDefaults:
998+
- type: ALTERNATE_TYPE_DC
999+
value: default
9801000
timeouts:
9811001
name: timeouts
9821002
title: Timeouts
@@ -989,6 +1009,12 @@ spec:
9891009
workload_identity_config:
9901010
name: workload_identity_config
9911011
title: Workload Identity Config
1012+
properties:
1013+
workload_pool:
1014+
name: workload_pool
1015+
title: Workload Pool
1016+
regexValidation: ^[a-z]([-a-z0-9]{4,28}[a-z0-9])\.svc\.id\.goog$
1017+
validation: Workload pool must be in the format <project_id>.svc.id.goog. project_id must be between 6 and 30 characters can have lowercase letters, digits, or hyphens. It must start with a lowercase letter and end with a letter or number.
9921018
runtime:
9931019
outputs:
9941020
cluster_id:

modules/gke-standard-cluster/metadata.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ spec:
359359
}))
360360
})
361361
- name: master_authorized_networks_config
362-
description: The desired configuration options for master authorized networks.
362+
description: The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)
363363
varType: |-
364364
object({
365365
cidr_blocks = list(object({
@@ -1013,9 +1013,9 @@ spec:
10131013
roles:
10141014
- level: Project
10151015
roles:
1016-
- roles/iam.serviceAccountUser
10171016
- roles/compute.admin
10181017
- roles/container.admin
1018+
- roles/iam.serviceAccountUser
10191019
services:
10201020
- compute.googleapis.com
10211021
- container.googleapis.com

modules/gke-standard-cluster/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ variable "master_auth" {
309309
}
310310

311311
variable "master_authorized_networks_config" {
312-
description = "The desired configuration options for master authorized networks."
312+
description = "The desired configuration options for master authorized networks. Cidr Block must follow [Cidr notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)"
313313
type = object({
314314
cidr_blocks = list(object({
315315
display_name = string

0 commit comments

Comments
 (0)