Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Introduce variables for destroying things (#2398)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Jun 29, 2023
1 parent 214bd8e commit 5a27cc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion terraform/build.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "google_storage_bucket" "cloudbuild-cache" {
name = "${var.project}-cloudbuild-cache"
location = var.storage_location

force_destroy = true
force_destroy = var.force_destroy
uniform_bucket_level_access = true

// Automatically expire cached objects.
Expand Down
6 changes: 5 additions & 1 deletion terraform/database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ resource "google_sql_database_instance" "db-inst" {
region = var.region
database_version = var.database_version

deletion_protection = !var.force_destroy

settings {
tier = var.database_tier
disk_size = var.database_disk_size_gb
Expand Down Expand Up @@ -98,6 +100,8 @@ resource "google_sql_database_instance" "replicas" {

master_instance_name = google_sql_database_instance.db-inst.name

deletion_protection = !var.force_destroy

// These are REGIONAL replicas, which cannot auto-failover. The default
// configuration has auto-failover in zones. This is for super disaster
// recovery in which an entire region is down for an extended period of time.
Expand Down Expand Up @@ -344,7 +348,7 @@ resource "google_storage_bucket" "backups" {
name = "${var.project}-backups"
location = var.storage_location

force_destroy = true
force_destroy = var.force_destroy
uniform_bucket_level_access = true

versioning {
Expand Down
7 changes: 7 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

variable "force_destroy" {
type = bool
default = false

description = "Allow resources like buckets and database instances to be destroyed."
}

variable "create_env_file" {
type = bool
default = false
Expand Down

0 comments on commit 5a27cc4

Please # to comment.