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

Introduce variables for destroying things #1625

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion terraform/build.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 @@ -17,6 +17,8 @@ resource "google_sql_database_instance" "db-inst" {
region = var.db_location
database_version = var.db_version

deletion_protection = !var.force_destroy

settings {
tier = var.cloudsql_tier
disk_size = var.cloudsql_disk_size_gb
Expand Down Expand Up @@ -81,6 +83,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 @@ -223,7 +227,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
2 changes: 2 additions & 0 deletions terraform/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ resource "google_storage_bucket" "export" {
type = "Delete"
}
}

force_destroy = var.force_destroy
}

resource "google_storage_bucket_iam_member" "public" {
Expand Down
7 changes: 7 additions & 0 deletions terraform/vars.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