hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.28k stars 1.72k forks source link

Add deletion_protection attribute to google_project resource #12277

Open linouk23 opened 2 years ago

linouk23 commented 2 years ago

Community Note

Description

Did we consider adding deletion_protection attribute (similar to google_bigquery_table resource to prevent users from accidentally deleting the project?

image

image

New or Affected Resource(s)

Potential Terraform Configuration

resource "google_project" "my_project" {
  name       = "My Project"
  project_id = "your-project-id"
  org_id     = "1234567"
  # new deletion_protection attribute that defaults to true
}

b/350514911

rileykarson commented 2 years ago

Note: There's a built-in GCP resource to add addtl deletion protection past Terraform's plan stage / lifecycle rule, https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/resource_manager_lien.

It's still opt-in, so an opt-out deletion_protection is still valuable, but less so that for some other resources w/o addtl protections.

haizaar commented 1 year ago

Agree with @rileykarson that while liens are useful if deletion is attempted outside of TF, removing lien definition together with project definition from a .tf file will cause TF to happily nuke both.

Hence having opt-out deletion_protection option will be useful.