Skip to content

Commit 9ff1b5e

Browse files
DrFaust92Amine Laabi
and
Amine Laabi
authored
feat: add notification event filter (#1996)
Co-authored-by: Amine Laabi <amine.laabi@servier.com>
1 parent 4274b0e commit 9ff1b5e

File tree

29 files changed

+141
-2
lines changed

29 files changed

+141
-2
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Then perform the following commands on the root folder:
222222
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
223223
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
224224
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
225+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
225226
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
226227
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
227228
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: autogen/main/cluster.tf.tmpl

+7
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,13 @@ resource "google_container_cluster" "primary" {
628628
pubsub {
629629
enabled = var.notification_config_topic != "" ? true : false
630630
topic = var.notification_config_topic
631+
632+
dynamic "filter" {
633+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
634+
content {
635+
event_type = var.notification_filter_event_type
636+
}
637+
}
631638
}
632639
}
633640
{% if beta_cluster and autopilot_cluster != true %}

Diff for: autogen/main/variables.tf.tmpl

+8-2
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,15 @@ variable "disable_default_snat" {
620620
}
621621

622622
variable "notification_config_topic" {
623-
type = string
623+
type = string
624624
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
625-
default = ""
625+
default = ""
626+
}
627+
628+
variable "notification_filter_event_type" {
629+
type = list(string)
630+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
631+
default = []
626632
}
627633

628634
variable "deletion_protection" {

Diff for: cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ resource "google_container_cluster" "primary" {
465465
pubsub {
466466
enabled = var.notification_config_topic != "" ? true : false
467467
topic = var.notification_config_topic
468+
469+
dynamic "filter" {
470+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
471+
content {
472+
event_type = var.notification_filter_event_type
473+
}
474+
}
468475
}
469476
}
470477
}

Diff for: modules/beta-autopilot-private-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Then perform the following commands on the root folder:
130130
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
131131
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
132132
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
133+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
133134
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
134135
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
135136
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-autopilot-private-cluster/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ resource "google_container_cluster" "primary" {
296296
pubsub {
297297
enabled = var.notification_config_topic != "" ? true : false
298298
topic = var.notification_config_topic
299+
300+
dynamic "filter" {
301+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
302+
content {
303+
event_type = var.notification_filter_event_type
304+
}
305+
}
299306
}
300307
}
301308

Diff for: modules/beta-autopilot-private-cluster/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ variable "notification_config_topic" {
430430
default = ""
431431
}
432432

433+
variable "notification_filter_event_type" {
434+
type = list(string)
435+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
436+
default = []
437+
}
438+
433439
variable "deletion_protection" {
434440
type = bool
435441
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/beta-autopilot-public-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Then perform the following commands on the root folder:
119119
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
120120
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
121121
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
122+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
122123
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
123124
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
124125
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-autopilot-public-cluster/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ resource "google_container_cluster" "primary" {
277277
pubsub {
278278
enabled = var.notification_config_topic != "" ? true : false
279279
topic = var.notification_config_topic
280+
281+
dynamic "filter" {
282+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
283+
content {
284+
event_type = var.notification_filter_event_type
285+
}
286+
}
280287
}
281288
}
282289

Diff for: modules/beta-autopilot-public-cluster/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ variable "notification_config_topic" {
400400
default = ""
401401
}
402402

403+
variable "notification_filter_event_type" {
404+
type = list(string)
405+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
406+
default = []
407+
}
408+
403409
variable "deletion_protection" {
404410
type = bool
405411
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/beta-private-cluster-update-variant/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ Then perform the following commands on the root folder:
270270
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
271271
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
272272
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
273+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
273274
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
274275
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
275276
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-private-cluster-update-variant/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,13 @@ resource "google_container_cluster" "primary" {
544544
pubsub {
545545
enabled = var.notification_config_topic != "" ? true : false
546546
topic = var.notification_config_topic
547+
548+
dynamic "filter" {
549+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
550+
content {
551+
event_type = var.notification_filter_event_type
552+
}
553+
}
547554
}
548555
}
549556

Diff for: modules/beta-private-cluster-update-variant/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,12 @@ variable "notification_config_topic" {
599599
default = ""
600600
}
601601

602+
variable "notification_filter_event_type" {
603+
type = list(string)
604+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
605+
default = []
606+
}
607+
602608
variable "deletion_protection" {
603609
type = bool
604610
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/beta-private-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ Then perform the following commands on the root folder:
248248
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
249249
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
250250
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
251+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
251252
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
252253
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
253254
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-private-cluster/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,13 @@ resource "google_container_cluster" "primary" {
544544
pubsub {
545545
enabled = var.notification_config_topic != "" ? true : false
546546
topic = var.notification_config_topic
547+
548+
dynamic "filter" {
549+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
550+
content {
551+
event_type = var.notification_filter_event_type
552+
}
553+
}
547554
}
548555
}
549556

Diff for: modules/beta-private-cluster/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,12 @@ variable "notification_config_topic" {
599599
default = ""
600600
}
601601

602+
variable "notification_filter_event_type" {
603+
type = list(string)
604+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
605+
default = []
606+
}
607+
602608
variable "deletion_protection" {
603609
type = bool
604610
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/beta-public-cluster-update-variant/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Then perform the following commands on the root folder:
259259
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
260260
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
261261
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
262+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
262263
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
263264
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
264265
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-public-cluster-update-variant/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,13 @@ resource "google_container_cluster" "primary" {
525525
pubsub {
526526
enabled = var.notification_config_topic != "" ? true : false
527527
topic = var.notification_config_topic
528+
529+
dynamic "filter" {
530+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
531+
content {
532+
event_type = var.notification_filter_event_type
533+
}
534+
}
528535
}
529536
}
530537

Diff for: modules/beta-public-cluster-update-variant/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ variable "notification_config_topic" {
569569
default = ""
570570
}
571571

572+
variable "notification_filter_event_type" {
573+
type = list(string)
574+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
575+
default = []
576+
}
577+
572578
variable "deletion_protection" {
573579
type = bool
574580
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/beta-public-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Then perform the following commands on the root folder:
237237
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
238238
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
239239
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
240+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
240241
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
241242
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
242243
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/beta-public-cluster/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,13 @@ resource "google_container_cluster" "primary" {
525525
pubsub {
526526
enabled = var.notification_config_topic != "" ? true : false
527527
topic = var.notification_config_topic
528+
529+
dynamic "filter" {
530+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
531+
content {
532+
event_type = var.notification_filter_event_type
533+
}
534+
}
528535
}
529536
}
530537

Diff for: modules/beta-public-cluster/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ variable "notification_config_topic" {
569569
default = ""
570570
}
571571

572+
variable "notification_filter_event_type" {
573+
type = list(string)
574+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
575+
default = []
576+
}
577+
572578
variable "deletion_protection" {
573579
type = bool
574580
description = "Whether or not to allow Terraform to destroy the cluster."

Diff for: modules/private-cluster-update-variant/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ Then perform the following commands on the root folder:
255255
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
256256
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
257257
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
258+
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
258259
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
259260
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
260261
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |

Diff for: modules/private-cluster-update-variant/cluster.tf

+7
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,13 @@ resource "google_container_cluster" "primary" {
484484
pubsub {
485485
enabled = var.notification_config_topic != "" ? true : false
486486
topic = var.notification_config_topic
487+
488+
dynamic "filter" {
489+
for_each = length(var.notification_filter_event_type) > 0 ? [1] : []
490+
content {
491+
event_type = var.notification_filter_event_type
492+
}
493+
}
487494
}
488495
}
489496
}

Diff for: modules/private-cluster-update-variant/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,12 @@ variable "notification_config_topic" {
574574
default = ""
575575
}
576576

577+
variable "notification_filter_event_type" {
578+
type = list(string)
579+
description = "Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT."
580+
default = []
581+
}
582+
577583
variable "deletion_protection" {
578584
type = bool
579585
description = "Whether or not to allow Terraform to destroy the cluster."

0 commit comments

Comments
 (0)