Make deletion protection consistent across all modules (#1735)
* Expose deletion_protection in GKE modules * Make deletion protection consistent across all modules * Add deletion_protection option to blueprints * Fix blueprints tests * Fix types * Update READMEs * Fix dp readme * Fix cmek blueprint default deletion_protection * Fix blueprints tests
This commit is contained in:
@@ -88,18 +88,18 @@ You can connect your hub to on-premises using Cloud Interconnect or HA VPN. On-p
|
||||
|
||||
You can add additional spoke to the architecture. All of these spokes have networking similar to spoke-1: They will have connectivity to the hub and to spoke-2, but not to each other unless you also create VPN tunnels for the new spokes.
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [prefix](variables.tf#L34) | Prefix used for resource names. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L69) | Project id used for all resources. | <code>string</code> | ✓ | |
|
||||
| [ip_ranges](variables.tf#L15) | IP CIDR ranges. | <code>map(string)</code> | | <code title="{ hub = "10.0.0.0/24" spoke-1 = "10.0.16.0/24" spoke-2 = "10.0.32.0/24" }">{…}</code> |
|
||||
| [ip_secondary_ranges](variables.tf#L25) | Secondary IP CIDR ranges. | <code>map(string)</code> | | <code title="{ spoke-2-pods = "10.128.0.0/18" spoke-2-services = "172.16.0.0/24" }">{…}</code> |
|
||||
| [private_service_ranges](variables.tf#L43) | Private service IP CIDR ranges. | <code>map(string)</code> | | <code title="{ spoke-2-cluster-1 = "192.168.0.0/28" }">{…}</code> |
|
||||
| [project_create](variables.tf#L51) | Set to non null if project needs to be created. | <code title="object({ billing_account = string oslogin = bool parent = string })">object({…})</code> | | <code>null</code> |
|
||||
| [region](variables.tf#L74) | VPC region. | <code>string</code> | | <code>"europe-west1"</code> |
|
||||
| [prefix](variables.tf#L41) | Prefix used for resource names. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L76) | Project id used for all resources. | <code>string</code> | ✓ | |
|
||||
| [deletion_protection](variables.tf#L15) | Prevent Terraform from destroying data storage resources (storage buckets, GKE clusters, CloudSQL instances) in this blueprint. When this field is set in Terraform state, a terraform destroy or terraform apply that would delete data storage resources will fail. | <code>bool</code> | | <code>false</code> |
|
||||
| [ip_ranges](variables.tf#L22) | IP CIDR ranges. | <code>map(string)</code> | | <code title="{ hub = "10.0.0.0/24" spoke-1 = "10.0.16.0/24" spoke-2 = "10.0.32.0/24" }">{…}</code> |
|
||||
| [ip_secondary_ranges](variables.tf#L32) | Secondary IP CIDR ranges. | <code>map(string)</code> | | <code title="{ spoke-2-pods = "10.128.0.0/18" spoke-2-services = "172.16.0.0/24" }">{…}</code> |
|
||||
| [private_service_ranges](variables.tf#L50) | Private service IP CIDR ranges. | <code>map(string)</code> | | <code title="{ spoke-2-cluster-1 = "192.168.0.0/28" }">{…}</code> |
|
||||
| [project_create](variables.tf#L58) | Set to non null if project needs to be created. | <code title="object({ billing_account = string oslogin = bool parent = string })">object({…})</code> | | <code>null</code> |
|
||||
| [region](variables.tf#L81) | VPC region. | <code>string</code> | | <code>"europe-west1"</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
@@ -107,7 +107,6 @@ You can add additional spoke to the architecture. All of these spokes have netwo
|
||||
|---|---|:---:|
|
||||
| [project](outputs.tf#L15) | Project id. | |
|
||||
| [vms](outputs.tf#L20) | GCE VMs. | |
|
||||
|
||||
<!-- END TFDOC -->
|
||||
## Test
|
||||
|
||||
|
||||
@@ -274,6 +274,7 @@ module "cluster-1" {
|
||||
import_routes = false
|
||||
}
|
||||
}
|
||||
deletion_protection = var.deletion_protection
|
||||
}
|
||||
|
||||
module "cluster-1-nodepool-1" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2022 Google LLC
|
||||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
variable "deletion_protection" {
|
||||
description = "Prevent Terraform from destroying data storage resources (storage buckets, GKE clusters, CloudSQL instances) in this blueprint. When this field is set in Terraform state, a terraform destroy or terraform apply that would delete data storage resources will fail."
|
||||
type = bool
|
||||
default = false
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "ip_ranges" {
|
||||
description = "IP CIDR ranges."
|
||||
type = map(string)
|
||||
|
||||
@@ -42,23 +42,23 @@ alias k='HTTPS_PROXY=localhost:8888 kubectl $@'
|
||||
|
||||
There's a minor glitch that can surface running `terraform destroy`, where the service project attachments to the Shared VPC will not get destroyed even with the relevant API call succeeding. We are investigating the issue, in the meantime just manually remove the attachment in the Cloud console or via the `gcloud beta compute shared-vpc associated-projects remove` command when `terraform destroy` fails, and then relaunch the command.
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [billing_account_id](variables.tf#L15) | Billing account id used as default for new projects. | <code>string</code> | ✓ | |
|
||||
| [prefix](variables.tf#L62) | Prefix used for resource names. | <code>string</code> | ✓ | |
|
||||
| [root_node](variables.tf#L94) | Hierarchy node where projects will be created, 'organizations/org_id' or 'folders/folder_id'. | <code>string</code> | ✓ | |
|
||||
| [prefix](variables.tf#L69) | Prefix used for resource names. | <code>string</code> | ✓ | |
|
||||
| [root_node](variables.tf#L101) | Hierarchy node where projects will be created, 'organizations/org_id' or 'folders/folder_id'. | <code>string</code> | ✓ | |
|
||||
| [cluster_create](variables.tf#L20) | Create GKE cluster and nodepool. | <code>bool</code> | | <code>true</code> |
|
||||
| [ip_ranges](variables.tf#L26) | Subnet IP CIDR ranges. | <code>map(string)</code> | | <code title="{ gce = "10.0.16.0/24" gke = "10.0.32.0/24" }">{…}</code> |
|
||||
| [ip_secondary_ranges](variables.tf#L35) | Secondary IP CIDR ranges. | <code>map(string)</code> | | <code title="{ gke-pods = "10.128.0.0/18" gke-services = "172.16.0.0/24" }">{…}</code> |
|
||||
| [owners_gce](variables.tf#L44) | GCE project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [owners_gke](variables.tf#L50) | GKE project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [owners_host](variables.tf#L56) | Host project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_service_ranges](variables.tf#L71) | Private service IP CIDR ranges. | <code>map(string)</code> | | <code title="{ cluster-1 = "192.168.0.0/28" }">{…}</code> |
|
||||
| [project_services](variables.tf#L79) | Service APIs enabled by default in new projects. | <code>list(string)</code> | | <code title="[ "container.googleapis.com", "stackdriver.googleapis.com", ]">[…]</code> |
|
||||
| [region](variables.tf#L88) | Region used. | <code>string</code> | | <code>"europe-west1"</code> |
|
||||
| [deletion_protection](variables.tf#L26) | Prevent Terraform from destroying data storage resources (storage buckets, GKE clusters, CloudSQL instances) in this blueprint. When this field is set in Terraform state, a terraform destroy or terraform apply that would delete data storage resources will fail. | <code>bool</code> | | <code>false</code> |
|
||||
| [ip_ranges](variables.tf#L33) | Subnet IP CIDR ranges. | <code>map(string)</code> | | <code title="{ gce = "10.0.16.0/24" gke = "10.0.32.0/24" }">{…}</code> |
|
||||
| [ip_secondary_ranges](variables.tf#L42) | Secondary IP CIDR ranges. | <code>map(string)</code> | | <code title="{ gke-pods = "10.128.0.0/18" gke-services = "172.16.0.0/24" }">{…}</code> |
|
||||
| [owners_gce](variables.tf#L51) | GCE project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [owners_gke](variables.tf#L57) | GKE project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [owners_host](variables.tf#L63) | Host project owners, in IAM format. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_service_ranges](variables.tf#L78) | Private service IP CIDR ranges. | <code>map(string)</code> | | <code title="{ cluster-1 = "192.168.0.0/28" }">{…}</code> |
|
||||
| [project_services](variables.tf#L86) | Service APIs enabled by default in new projects. | <code>list(string)</code> | | <code title="[ "container.googleapis.com", "stackdriver.googleapis.com", ]">[…]</code> |
|
||||
| [region](variables.tf#L95) | Region used. | <code>string</code> | | <code>"europe-west1"</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
@@ -68,9 +68,7 @@ There's a minor glitch that can surface running `terraform destroy`, where the s
|
||||
| [projects](outputs.tf#L24) | Project ids. | |
|
||||
| [vms](outputs.tf#L33) | GCE VMs. | |
|
||||
| [vpc](outputs.tf#L40) | Shared VPC. | |
|
||||
|
||||
<!-- END TFDOC -->
|
||||
|
||||
## Test
|
||||
|
||||
```hcl
|
||||
|
||||
@@ -223,6 +223,7 @@ module "cluster-1" {
|
||||
labels = {
|
||||
environment = "test"
|
||||
}
|
||||
deletion_protection = var.deletion_protection
|
||||
}
|
||||
|
||||
module "cluster-1-nodepool-1" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2022 Google LLC
|
||||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,13 @@ variable "cluster_create" {
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "deletion_protection" {
|
||||
description = "Prevent Terraform from destroying data storage resources (storage buckets, GKE clusters, CloudSQL instances) in this blueprint. When this field is set in Terraform state, a terraform destroy or terraform apply that would delete data storage resources will fail."
|
||||
type = bool
|
||||
default = false
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "ip_ranges" {
|
||||
description = "Subnet IP CIDR ranges."
|
||||
type = map(string)
|
||||
|
||||
Reference in New Issue
Block a user