diff --git a/modules/gcs/outputs.tf b/modules/gcs/outputs.tf
index ce865f2b0..ee21b9d11 100644
--- a/modules/gcs/outputs.tf
+++ b/modules/gcs/outputs.tf
@@ -25,11 +25,11 @@ output "name" {
}
output "notification" {
description = "GCS Notification self link."
- value = local.notification == true ? google_storage_notification.notification[0].self_link : null
+ value = local.notification ? google_storage_notification.notification[0].self_link : null
}
output "topic" {
description = "Topic ID used by GCS."
- value = local.notification == true ? google_pubsub_topic.topic[0].id : null
+ value = local.notification ? google_pubsub_topic.topic[0].id : null
}
output "url" {
description = "Bucket URL."
diff --git a/modules/gke-cluster/README.md b/modules/gke-cluster/README.md
index 9071d8bbd..dc6d18d71 100644
--- a/modules/gke-cluster/README.md
+++ b/modules/gke-cluster/README.md
@@ -98,6 +98,7 @@ module "cluster-1" {
| *monitoring_config* | Monitoring configuration (enabled components). | list(string) | | null |
| *monitoring_service* | Monitoring service (disable with an empty string). | string | | monitoring.googleapis.com/kubernetes |
| *node_locations* | Zones in which the cluster's nodes are located. | list(string) | | [] |
+| *notification_config* | GKE Cluster upgrade notifications via PubSub. | bool | | false |
| *peering_config* | Configure peering with the master VPC for private clusters. | object({...}) | | null |
| *pod_security_policy* | Enable the PodSecurityPolicy feature. | bool | | null |
| *private_cluster_config* | Enable and configure private cluster, private nodes must be true if used. | object({...}) | | null |
@@ -116,4 +117,5 @@ module "cluster-1" {
| location | Cluster location. | |
| master_version | Master version. | |
| name | Cluster name. | |
+| notifications | GKE PubSub notifications topic. | |
diff --git a/modules/gke-cluster/main.tf b/modules/gke-cluster/main.tf
index 26641338e..572e35c11 100644
--- a/modules/gke-cluster/main.tf
+++ b/modules/gke-cluster/main.tf
@@ -277,6 +277,16 @@ resource "google_container_cluster" "cluster" {
cluster_dns_domain = config.value.cluster_dns_domain
}
}
+
+ dynamic "notification_config" {
+ for_each = var.notification_config ? [""] : []
+ content {
+ pubsub {
+ enabled = var.notification_config
+ topic = var.notification_config ? google_pubsub_topic.notifications[0].id : null
+ }
+ }
+ }
}
resource "google_compute_network_peering_routes_config" "gke_master" {
@@ -287,3 +297,11 @@ resource "google_compute_network_peering_routes_config" "gke_master" {
import_custom_routes = var.peering_config.import_routes
export_custom_routes = var.peering_config.export_routes
}
+
+resource "google_pubsub_topic" "notifications" {
+ count = var.notification_config ? 1 : 0
+ name = "gke-pubsub-notifications"
+ labels = {
+ content = "gke-notifications"
+ }
+}
\ No newline at end of file
diff --git a/modules/gke-cluster/outputs.tf b/modules/gke-cluster/outputs.tf
index aab61c0d1..df0b40c18 100644
--- a/modules/gke-cluster/outputs.tf
+++ b/modules/gke-cluster/outputs.tf
@@ -45,3 +45,8 @@ output "name" {
description = "Cluster name."
value = google_container_cluster.cluster.name
}
+
+output "notifications" {
+ description = "GKE PubSub notifications topic."
+ value = var.notification_config ? google_pubsub_topic.notifications[0].id : null
+}
diff --git a/modules/gke-cluster/variables.tf b/modules/gke-cluster/variables.tf
index 5bcc316f5..4c2bf2ecd 100644
--- a/modules/gke-cluster/variables.tf
+++ b/modules/gke-cluster/variables.tf
@@ -237,6 +237,12 @@ variable "node_locations" {
default = []
}
+variable "notification_config" {
+ description = "GKE Cluster upgrade notifications via PubSub."
+ type = bool
+ default = false
+}
+
variable "peering_config" {
description = "Configure peering with the master VPC for private clusters."
type = object({