From 694241e8fb6129abb879764bf1e920c29e6eba08 Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Fri, 22 Nov 2024 07:15:09 +0000 Subject: [PATCH] fix: add deletion_protection to backup module and set it to false in intergration tests --- examples/postgresql-backup-provided-service-account/main.tf | 1 + modules/backup/main.tf | 1 + modules/backup/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/examples/postgresql-backup-provided-service-account/main.tf b/examples/postgresql-backup-provided-service-account/main.tf index fd18b856..e34c76e4 100644 --- a/examples/postgresql-backup-provided-service-account/main.tf +++ b/examples/postgresql-backup-provided-service-account/main.tf @@ -70,6 +70,7 @@ module "backup" { service_account = "${data.google_project.test_project.number}-compute@developer.gserviceaccount.com" create_notification_channel = false notification_channels = [google_monitoring_notification_channel.email.id] + deletion_protection = false } data "google_project" "test_project" { diff --git a/modules/backup/main.tf b/modules/backup/main.tf index d590738d..bd516779 100644 --- a/modules/backup/main.tf +++ b/modules/backup/main.tf @@ -99,6 +99,7 @@ resource "google_workflows_workflow" "sql_backup" { backupRetentionTime = var.backup_retention_time backupRunsListMaxResults = var.backup_runs_list_max_results }) + deletion_protection = var.deletion_protection } resource "google_cloud_scheduler_job" "sql_backup" { diff --git a/modules/backup/variables.tf b/modules/backup/variables.tf index 84d4bcf7..e08e0ad3 100644 --- a/modules/backup/variables.tf +++ b/modules/backup/variables.tf @@ -192,3 +192,9 @@ variable "notification_channels" { type = list(string) default = [] } + +variable "deletion_protection" { + description = "Whether Terraform will be prevented from destroying the workflow." + type = bool + default = true +} \ No newline at end of file