Skip to content

Commit

Permalink
feat: added notification_config block to beta submodules (#752)
Browse files Browse the repository at this point in the history
* feat: added notification_config block

* fix: terraform fmt

* fix: required_providers set to 3.42.0

* fix: google-beta only

* fix: removed `enable_notification_config`

* fix: terraform fmt
  • Loading branch information
odise committed Dec 2, 2020
1 parent 166fb24 commit 4a85321
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 5 deletions.
7 changes: 7 additions & 0 deletions autogen/main/cluster.tf.tmpl
Expand Up @@ -306,6 +306,13 @@ resource "google_container_cluster" "primary" {
security_group = authenticator_groups_config.value.security_group
}
}

notification_config {
pubsub {
enabled = var.notification_config_topic != "" ? true : false
topic = var.notification_config_topic
}
}
{% endif %}
}

Expand Down
8 changes: 8 additions & 0 deletions autogen/main/variables.tf.tmpl
Expand Up @@ -574,3 +574,11 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

{% if beta_cluster %}
variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
{% endif %}
2 changes: 1 addition & 1 deletion autogen/main/versions.tf.tmpl
Expand Up @@ -19,7 +19,7 @@ terraform {

required_providers {
{% if beta_cluster %}
google-beta = ">= 3.32.0, <4.0.0"
google-beta = ">= 3.42.0, <4.0.0"
{% else %}
google = ">= 3.39.0, <4.0.0"
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions autogen/safer-cluster/main.tf.tmpl
Expand Up @@ -166,4 +166,6 @@ module "gke" {
skip_provisioners = var.skip_provisioners

gce_pd_csi_driver = var.gce_pd_csi_driver

notification_config_topic = var.notification_config_topic
}
6 changes: 6 additions & 0 deletions autogen/safer-cluster/variables.tf.tmpl
Expand Up @@ -369,3 +369,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
6 changes: 6 additions & 0 deletions examples/safer_cluster/main.tf
Expand Up @@ -61,8 +61,14 @@ module "gke" {

istio = true
cloudrun = true

notification_config_topic = google_pubsub_topic.updates.id
}

data "google_client_config" "default" {
}

resource "google_pubsub_topic" "updates" {
name = "cluster-updates-${random_string.suffix.result}"
project = var.project_id
}
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/README.md
Expand Up @@ -214,6 +214,7 @@ Then perform the following commands on the root folder:
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Expand Up @@ -276,6 +276,13 @@ resource "google_container_cluster" "primary" {
security_group = authenticator_groups_config.value.security_group
}
}

notification_config {
pubsub {
enabled = var.notification_config_topic != "" ? true : false
topic = var.notification_config_topic
}
}
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Expand Up @@ -556,3 +556,9 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = ">=0.12.6, <0.14"

required_providers {
google-beta = ">= 3.32.0, <4.0.0"
google-beta = ">= 3.42.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Expand Up @@ -192,6 +192,7 @@ Then perform the following commands on the root folder:
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Expand Up @@ -276,6 +276,13 @@ resource "google_container_cluster" "primary" {
security_group = authenticator_groups_config.value.security_group
}
}

notification_config {
pubsub {
enabled = var.notification_config_topic != "" ? true : false
topic = var.notification_config_topic
}
}
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster/variables.tf
Expand Up @@ -556,3 +556,9 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = ">=0.12.6, <0.14"

required_providers {
google-beta = ">= 3.32.0, <4.0.0"
google-beta = ">= 3.42.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster-update-variant/README.md
Expand Up @@ -203,6 +203,7 @@ Then perform the following commands on the root folder:
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Expand Up @@ -257,6 +257,13 @@ resource "google_container_cluster" "primary" {
security_group = authenticator_groups_config.value.security_group
}
}

notification_config {
pubsub {
enabled = var.notification_config_topic != "" ? true : false
topic = var.notification_config_topic
}
}
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Expand Up @@ -525,3 +525,9 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = ">=0.12.6, <0.14"

required_providers {
google-beta = ">= 3.32.0, <4.0.0"
google-beta = ">= 3.42.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Expand Up @@ -181,6 +181,7 @@ Then perform the following commands on the root folder:
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster/cluster.tf
Expand Up @@ -257,6 +257,13 @@ resource "google_container_cluster" "primary" {
security_group = authenticator_groups_config.value.security_group
}
}

notification_config {
pubsub {
enabled = var.notification_config_topic != "" ? true : false
topic = var.notification_config_topic
}
}
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster/variables.tf
Expand Up @@ -525,3 +525,9 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/versions.tf
Expand Up @@ -18,6 +18,6 @@ terraform {
required_version = ">=0.12.6, <0.14"

required_providers {
google-beta = ">= 3.32.0, <4.0.0"
google-beta = ">= 3.42.0, <4.0.0"
}
}
1 change: 1 addition & 0 deletions modules/private-cluster-update-variant/variables.tf
Expand Up @@ -443,3 +443,4 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

1 change: 1 addition & 0 deletions modules/private-cluster/variables.tf
Expand Up @@ -443,3 +443,4 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

1 change: 1 addition & 0 deletions modules/safer-cluster-update-variant/README.md
Expand Up @@ -244,6 +244,7 @@ For simplicity, we suggest using `roles/container.admin` and
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in | `string` | n/a | yes |
| region | The region to host the cluster in | `string` | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/safer-cluster-update-variant/main.tf
Expand Up @@ -162,4 +162,6 @@ module "gke" {
skip_provisioners = var.skip_provisioners

gce_pd_csi_driver = var.gce_pd_csi_driver

notification_config_topic = var.notification_config_topic
}
6 changes: 6 additions & 0 deletions modules/safer-cluster-update-variant/variables.tf
Expand Up @@ -369,3 +369,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
1 change: 1 addition & 0 deletions modules/safer-cluster/README.md
Expand Up @@ -244,6 +244,7 @@ For simplicity, we suggest using `roles/container.admin` and
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| 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 |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in | `string` | n/a | yes |
| region | The region to host the cluster in | `string` | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/safer-cluster/main.tf
Expand Up @@ -162,4 +162,6 @@ module "gke" {
skip_provisioners = var.skip_provisioners

gce_pd_csi_driver = var.gce_pd_csi_driver

notification_config_topic = var.notification_config_topic
}
6 changes: 6 additions & 0 deletions modules/safer-cluster/variables.tf
Expand Up @@ -369,3 +369,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "notification_config_topic" {
type = string
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
default = ""
}
1 change: 1 addition & 0 deletions variables.tf
Expand Up @@ -419,3 +419,4 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

0 comments on commit 4a85321

Please sign in to comment.