diff --git a/main.tf b/main.tf index a63739b4..790c8e31 100644 --- a/main.tf +++ b/main.tf @@ -70,6 +70,7 @@ module "seed_project" { create_project_sa = false labels = var.project_labels lien = true + deletion_policy = var.project_deletion_policy } module "enable_cross_project_service_account_usage" { diff --git a/modules/cloudbuild/main.tf b/modules/cloudbuild/main.tf index 0314abf4..2381f1ae 100644 --- a/modules/cloudbuild/main.tf +++ b/modules/cloudbuild/main.tf @@ -45,6 +45,7 @@ module "cloudbuild_project" { billing_account = var.billing_account activate_apis = local.activate_apis labels = var.project_labels + deletion_policy = var.project_deletion_policy } /****************************************** diff --git a/modules/cloudbuild/variables.tf b/modules/cloudbuild/variables.tf index 1101673c..2519e248 100644 --- a/modules/cloudbuild/variables.tf +++ b/modules/cloudbuild/variables.tf @@ -77,6 +77,12 @@ variable "project_id" { type = string } +variable "project_deletion_policy" { + description = "The deletion policy for the project created." + type = string + default = "PREVENT" +} + variable "activate_apis" { description = "List of APIs to enable in the Cloudbuild project." type = list(string) diff --git a/modules/tf_cloudbuild_source/main.tf b/modules/tf_cloudbuild_source/main.tf index 7cc0f3c5..8454a435 100644 --- a/modules/tf_cloudbuild_source/main.tf +++ b/modules/tf_cloudbuild_source/main.tf @@ -43,6 +43,7 @@ module "cloudbuild_project" { billing_account = var.billing_account activate_apis = local.activate_apis labels = var.project_labels + deletion_policy = var.project_deletion_policy } // On the first run of cloud build submit, a bucket is automaticaly created with name "[PROJECT_ID]_cloudbuild" diff --git a/modules/tf_cloudbuild_source/variables.tf b/modules/tf_cloudbuild_source/variables.tf index 95f58fe3..c91ee4ce 100644 --- a/modules/tf_cloudbuild_source/variables.tf +++ b/modules/tf_cloudbuild_source/variables.tf @@ -31,6 +31,12 @@ variable "project_id" { type = string } +variable "project_deletion_policy" { + description = "The deletion policy for the project created." + type = string + default = "PREVENT" +} + variable "project_labels" { description = "Labels to apply to the project." type = map(string) diff --git a/test/setup/main.tf b/test/setup/main.tf index af7e604c..6dfd323e 100644 --- a/test/setup/main.tf +++ b/test/setup/main.tf @@ -23,6 +23,7 @@ module "project" { org_id = var.org_id folder_id = var.folder_id billing_account = var.billing_account + deletion_policy = "DELETE" activate_apis = [ "cloudresourcemanager.googleapis.com", diff --git a/test/setup/outputs.tf b/test/setup/outputs.tf index 2ff88e2d..cf2965f7 100644 --- a/test/setup/outputs.tf +++ b/test/setup/outputs.tf @@ -59,3 +59,7 @@ output "random_testing_string" { description = "Access the random ID created in setup for labeling other resources." value = random_id.suffix.hex } + +output "project_deletion_policy" { + value = "DELETE" +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index ba53b54d..cbf2d722 100644 --- a/variables.tf +++ b/variables.tf @@ -72,6 +72,12 @@ variable "project_id" { type = string } +variable "project_deletion_policy" { + description = "The deletion policy for the project created." + type = string + default = "PREVENT" +} + variable "activate_apis" { description = "List of APIs to enable in the seed project." type = list(string)