Support instance deletion protection (#56)
also bump google provider version to 3.57.0
This commit is contained in:
@@ -45,6 +45,9 @@ resource "google_sql_database_instance" "master" {
|
||||
region = var.region
|
||||
database_version = var.engine
|
||||
|
||||
# Whether or not to allow Terraform to destroy the instance.
|
||||
deletion_protection = var.deletion_protection
|
||||
|
||||
settings {
|
||||
tier = var.machine_type
|
||||
activation_policy = var.activation_policy
|
||||
@@ -173,6 +176,9 @@ resource "google_sql_database_instance" "failover_replica" {
|
||||
# The name of the instance that will act as the master in the replication setup.
|
||||
master_instance_name = google_sql_database_instance.master.name
|
||||
|
||||
# Whether or not to allow Terraform to destroy the instance.
|
||||
deletion_protection = var.deletion_protection
|
||||
|
||||
replica_configuration {
|
||||
# Specifies that the replica is the failover target.
|
||||
failover_target = true
|
||||
@@ -253,6 +259,9 @@ resource "google_sql_database_instance" "read_replica" {
|
||||
# The name of the instance that will act as the master in the replication setup.
|
||||
master_instance_name = google_sql_database_instance.master.name
|
||||
|
||||
# Whether or not to allow Terraform to destroy the instance.
|
||||
deletion_protection = var.deletion_protection
|
||||
|
||||
replica_configuration {
|
||||
# Specifies that the replica is not the failover target.
|
||||
failover_target = false
|
||||
|
||||
@@ -232,6 +232,13 @@ variable "resource_timeout" {
|
||||
default = "60m"
|
||||
}
|
||||
|
||||
# Whether or not to allow Terraform to destroy the instance.
|
||||
variable "deletion_protection" {
|
||||
description = "Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply command that deletes the instance will fail."
|
||||
type = bool
|
||||
default = "true"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
# MODULE DEPENDENCIES
|
||||
# Workaround Terraform limitation where there is no module depends_on.
|
||||
|
||||
Reference in New Issue
Block a user