diff --git a/mmv1/products/cloudrunv2/Job.yaml b/mmv1/products/cloudrunv2/Job.yaml index 0ff86aac88d7..3b14f068b606 100644 --- a/mmv1/products/cloudrunv2/Job.yaml +++ b/mmv1/products/cloudrunv2/Job.yaml @@ -50,6 +50,19 @@ iam_policy: !ruby/object:Api::Resource::IamPolicy id_format: 'projects/{{project}}/locations/{{location}}/jobs/{{name}}' import_format: ['projects/{{project}}/locations/{{location}}/jobs/{{name}}'] autogen_async: true +virtual_fields: + - !ruby/object:Api::Type::Boolean + name: 'deletion_protection' + default_value: true + description: | + Whether Terraform will be prevented from destroying the job. Defaults to true. + When a`terraform destroy` or `terraform apply` would delete the job, + the command will fail if this field is not set to false in Terraform state. + When the field is set to true or unset in Terraform state, a `terraform apply` + or `terraform destroy` that would delete the job will fail. + When the field is set to false, deleting the job is allowed. +custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_delete: 'templates/terraform/pre_delete/cloudrunv2_job_deletion_policy.go.erb' examples: - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_basic' @@ -59,11 +72,15 @@ examples: ])" vars: cloud_run_job_name: 'cloudrun-job' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_limits' primary_resource_id: 'default' vars: cloud_run_job_name: 'cloudrun-job' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_sql' primary_resource_id: 'default' @@ -79,6 +96,8 @@ examples: deletion_protection: 'false' oics_vars_overrides: deletion_protection: 'false' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_vpcaccess' primary_resource_id: 'default' @@ -90,6 +109,8 @@ examples: vpc_access_connector_name: 'run-vpc' vpc_compute_subnetwork_name: 'run-subnetwork' compute_network_name: 'run-network' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_directvpc' primary_resource_id: 'default' @@ -97,6 +118,8 @@ examples: ])" vars: cloud_run_job_name: 'cloudrun-job' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_secret' primary_resource_id: 'default' @@ -106,6 +129,8 @@ examples: vars: cloud_run_job_name: 'cloudrun-job' secret_id: 'secret' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_emptydir' min_version: 'beta' @@ -114,6 +139,8 @@ examples: ])" vars: cloud_run_job_name: 'cloudrun-job' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_job_run_job' min_version: beta @@ -122,6 +149,8 @@ examples: ])" vars: cloud_run_job_name: 'cloudrun-job' + ignore_read_extra: + - 'deletion_protection' parameters: - !ruby/object:Api::Type::String name: 'location' diff --git a/mmv1/products/cloudrunv2/Service.yaml b/mmv1/products/cloudrunv2/Service.yaml index 53313970e5b8..b5bca420f688 100644 --- a/mmv1/products/cloudrunv2/Service.yaml +++ b/mmv1/products/cloudrunv2/Service.yaml @@ -49,6 +49,19 @@ async: !ruby/object:Api::OpAsync id_format: 'projects/{{project}}/locations/{{location}}/services/{{name}}' import_format: ['projects/{{project}}/locations/{{location}}/services/{{name}}'] autogen_async: true +virtual_fields: + - !ruby/object:Api::Type::Boolean + name: 'deletion_protection' + default_value: true + description: | + Whether Terraform will be prevented from destroying the service. Defaults to true. + When a`terraform destroy` or `terraform apply` would delete the service, + the command will fail if this field is not set to false in Terraform state. + When the field is set to true or unset in Terraform state, a `terraform apply` + or `terraform destroy` that would delete the service will fail. + When the field is set to false, deleting the service is allowed. +custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_delete: 'templates/terraform/pre_delete/cloudrunv2_service_deletion_policy.go.erb' examples: - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_basic' @@ -56,11 +69,15 @@ examples: primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-service%s\", context[\"random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_limits' primary_resource_id: 'default' vars: cloud_run_service_name: 'cloudrun-service' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_sql' primary_resource_id: 'default' @@ -74,6 +91,8 @@ examples: deletion_protection: 'false' oics_vars_overrides: deletion_protection: 'false' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_vpcaccess' primary_resource_id: 'default' @@ -83,18 +102,24 @@ examples: vpc_access_connector_name: 'run-vpc' vpc_compute_subnetwork_name: 'run-subnetwork' compute_network_name: 'run-network' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_directvpc' primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-srv%s\", context[\"random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_probes' primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-srv%s\", context[\"random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_secret' primary_resource_id: 'default' @@ -102,6 +127,8 @@ examples: vars: cloud_run_service_name: 'cloudrun-service' secret_id: 'secret-1' + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_multicontainer' min_version: 'beta' @@ -110,20 +137,24 @@ examples: random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' - + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_mount_gcs' primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-service-%s\", context[\"random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' - + ignore_read_extra: + - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_mount_nfs' primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-service-%s\", context[\"random_suffix\"])" vars: cloud_run_service_name: 'cloudrun-service' + ignore_read_extra: + - 'deletion_protection' parameters: - !ruby/object:Api::Type::String diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_basic.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_basic.tf.erb index 95f66200f790..5eb48cde2e78 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_basic.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_basic.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_directvpc.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_directvpc.tf.erb index d8117c68cd1a..805f703159ed 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_directvpc.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_directvpc.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { template{ diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_emptydir.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_emptydir.tf.erb index 7095215262ce..3da094327bf6 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_emptydir.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_emptydir.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { provider = google-beta name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_limits.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_limits.tf.erb index d68c75898eeb..ced507f858c6 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_limits.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_limits.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_run_job.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_run_job.tf.erb index 16725f25fd99..51d19bb56b3a 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_run_job.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_run_job.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { provider = google-beta name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false start_execution_token = "start-once-created" template { template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_secret.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_secret.tf.erb index 102b4ee6dae0..325610803de3 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_secret.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_secret.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_sql.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_sql.tf.erb index 235d596612df..db875e95ecb2 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_sql.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_sql.tf.erb @@ -1,7 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" - + deletion_protection = false template { template{ volumes { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_job_vpcaccess.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_job_vpcaccess.tf.erb index dad5db7c6c9f..6755d8559ccc 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_job_vpcaccess.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_job_vpcaccess.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_job_name'] %>" location = "us-central1" + deletion_protection = false template { template{ diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_basic.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_basic.tf.erb index ecddc0b4b972..e5ce45478ff6 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_basic.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_basic.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_custom_audiences.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_custom_audiences.tf.erb index 50445e63e7e5..d77d23beae67 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_custom_audiences.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_custom_audiences.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { provider = google-beta name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_directvpc.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_directvpc.tf.erb index 530931f74504..8460569c6d0f 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_directvpc.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_directvpc.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_limits.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_limits.tf.erb index 30476a53159e..2c166453536f 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_limits.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_limits.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_mount_gcs.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_mount_gcs.tf.erb index 802110524ba3..396dd3a845af 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_mount_gcs.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_mount_gcs.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_mount_nfs.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_mount_nfs.tf.erb index 9f3451907065..e8c684382c97 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_mount_nfs.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_mount_nfs.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" launch_stage = "BETA" diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_multicontainer.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_multicontainer.tf.erb index c5d31ad40d13..6696c55c00ba 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_multicontainer.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_multicontainer.tf.erb @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { provider = google-beta name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_probes.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_probes.tf.erb index 22b763d5c052..7bab08c7ffa9 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_probes.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_probes.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false template { containers { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_secret.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_secret.tf.erb index 5b06cd4ad619..5c89dbf447f6 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_secret.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_secret.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_sql.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_sql.tf.erb index 9a05e52a98f3..ff89c69f0a1a 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_sql.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_sql.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/cloudrunv2_service_vpcaccess.tf.erb b/mmv1/templates/terraform/examples/cloudrunv2_service_vpcaccess.tf.erb index 416c4d3e1969..6573ae4bbcc2 100644 --- a/mmv1/templates/terraform/examples/cloudrunv2_service_vpcaccess.tf.erb +++ b/mmv1/templates/terraform/examples/cloudrunv2_service_vpcaccess.tf.erb @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cloud_run_service_name'] %>" location = "us-central1" + deletion_protection = false template { containers { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_basic.tf.tmpl index 69c80116cd54..f32711e510d1 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_basic.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_directvpc.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_directvpc.tf.tmpl index 4a869bf081d1..3c8ca197aaef 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_directvpc.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_directvpc.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { template{ diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_emptydir.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_emptydir.tf.tmpl index 7231e35938a0..fbabbe991fd8 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_emptydir.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_emptydir.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { provider = google-beta name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_limits.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_limits.tf.tmpl index 5d2ae17ba840..c1ba237176f3 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_limits.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_limits.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_run_job.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_run_job.tf.tmpl index 329025cdb242..438eeab91d8f 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_run_job.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_run_job.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { provider = google-beta name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false start_execution_token = "start-once-created" template { template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_secret.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_secret.tf.tmpl index 34a753f31bba..520ef2410540 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_secret.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_secret.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false template { template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_sql.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_sql.tf.tmpl index e1f652e4145c..3dd95f7ce2ca 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_sql.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_sql.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false template { template{ diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_job_vpcaccess.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_job_vpcaccess.tf.tmpl index a2f00a6fdf6f..39cbc126eaf9 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_job_vpcaccess.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_job_vpcaccess.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_job" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_job_name"}}" location = "us-central1" + deletion_protection = false template { template{ diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_basic.tf.tmpl index dbcff1f1a3f9..2949efc82151 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_basic.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_custom_audiences.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_custom_audiences.tf.tmpl index 4b511b8a92de..7530526f6b0c 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_custom_audiences.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_custom_audiences.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { provider = google-beta name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_directvpc.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_directvpc.tf.tmpl index 502ffc36f77a..5fbee602618e 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_directvpc.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_directvpc.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_limits.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_limits.tf.tmpl index 12ccb1d11ae0..5929b55b4757 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_limits.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_limits.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_gcs.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_gcs.tf.tmpl index 8921ad840b10..8a2b39996a0d 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_gcs.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_gcs.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_nfs.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_nfs.tf.tmpl index c1cd7667cfcc..fa77b3569c35 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_nfs.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_mount_nfs.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" launch_stage = "BETA" diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_multicontainer.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_multicontainer.tf.tmpl index b34230a8d239..9ee26f40bda1 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_multicontainer.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_multicontainer.tf.tmpl @@ -2,6 +2,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { provider = google-beta name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_probes.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_probes.tf.tmpl index 51edcd7a8aef..7c4adc1f1e6d 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_probes.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_probes.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false template { containers { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_secret.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_secret.tf.tmpl index a350573ecd8c..6755d1de94d7 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_secret.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_secret.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_sql.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_sql.tf.tmpl index 7c3da92a2ccf..6c873e5696e2 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_sql.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_sql.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/templates/terraform/examples/go/cloudrunv2_service_vpcaccess.tf.tmpl b/mmv1/templates/terraform/examples/go/cloudrunv2_service_vpcaccess.tf.tmpl index 537ecb3c28bf..cc005f756b99 100644 --- a/mmv1/templates/terraform/examples/go/cloudrunv2_service_vpcaccess.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloudrunv2_service_vpcaccess.tf.tmpl @@ -1,6 +1,7 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "cloud_run_service_name"}}" location = "us-central1" + deletion_protection = false template { containers { diff --git a/mmv1/templates/terraform/pre_delete/cloudrunv2_job_deletion_policy.go.erb b/mmv1/templates/terraform/pre_delete/cloudrunv2_job_deletion_policy.go.erb new file mode 100644 index 000000000000..38c30189ea27 --- /dev/null +++ b/mmv1/templates/terraform/pre_delete/cloudrunv2_job_deletion_policy.go.erb @@ -0,0 +1,3 @@ +if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy job without setting deletion_protection=false and running `terraform apply`") +} \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_delete/cloudrunv2_service_deletion_policy.go.erb b/mmv1/templates/terraform/pre_delete/cloudrunv2_service_deletion_policy.go.erb new file mode 100644 index 000000000000..444ac1bfe13c --- /dev/null +++ b/mmv1/templates/terraform/pre_delete/cloudrunv2_service_deletion_policy.go.erb @@ -0,0 +1,3 @@ +if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy service without setting deletion_protection=false and running `terraform apply`") +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go b/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go index a3afa67f6769..e59989e2e0f5 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go +++ b/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go @@ -39,6 +39,7 @@ func testAccDataSourceGoogleCloudRunV2Job_basic(name, location string) string { resource "google_cloud_run_v2_job" "hello" { name = "%s" location = "%s" + deletion_protection = false template { template { @@ -100,6 +101,7 @@ func testAccDataSourceGoogleCloudRunV2Job_bindIAMPermission(name, location strin resource "google_cloud_run_v2_job" "hello" { name = "%s" location = "%s" + deletion_protection = false template { template { diff --git a/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go b/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go index 4c9cedb3c7e7..cb5921fa2567 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go +++ b/mmv1/third_party/terraform/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go @@ -39,6 +39,7 @@ func testAccDataSourceGoogleCloudRunV2Service_basic(name, location string) strin resource "google_cloud_run_v2_service" "hello" { name = "%s" location = "%s" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -93,6 +94,7 @@ func testAccDataSourceGoogleCloudRunV2Service_bindIAMPermission(name, location s resource "google_cloud_run_v2_service" "hello" { name = "%s" location = "%s" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { diff --git a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb index 828bef2161d8..42359093e225 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb @@ -37,7 +37,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobFullUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage", "labels", "terraform_labels", "annotations"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "labels", "terraform_labels", "annotations", "deletion_protection"}, }, }, }) @@ -116,6 +116,7 @@ func testAccCloudRunV2Job_cloudrunv2JobFullUpdate(context map[string]interface{} resource "google_cloud_run_v2_job" "default" { name = "tf-test-cloudrun-job%{random_suffix}" location = "us-central1" + deletion_protection = false binary_authorization { use_default = true breakglass_justification = "Some justification" @@ -227,7 +228,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(context), @@ -236,7 +237,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -247,6 +248,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPC(context map[string]interfac resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -275,6 +277,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(context map[string]in resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -321,7 +324,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context), @@ -330,7 +333,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -341,6 +344,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNoVolume(context map[string]interface resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -364,6 +368,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -407,7 +412,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context), @@ -416,7 +421,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -427,6 +432,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context map[string]interfac resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -476,7 +482,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithStartExecutionTokenUpdate(t *testing. ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithStartExecutionToken(context2), @@ -485,7 +491,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithStartExecutionTokenUpdate(t *testing. ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -496,6 +502,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithStartExecutionToken(context map[strin resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false start_execution_token = "%{token}" template { template { @@ -533,7 +540,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithRunExecutionTokenUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithRunExecutionToken(context2), @@ -542,7 +549,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithRunExecutionTokenUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -553,6 +560,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithRunExecutionToken(context map[string] resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false run_execution_token = "%{token}" template { template { diff --git a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb index f8d1109abe59..6525360e5c92 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb @@ -40,7 +40,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceFullUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "deletion_protection"}, }, }, }) @@ -116,6 +116,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description updating" location = "us-central1" + deletion_protection = false annotations = { generated-by = "magic-modules-files" } @@ -228,7 +229,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGcsVolume(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, }, }) @@ -240,6 +241,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" @@ -329,7 +331,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceTCPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithTCPStartupProbeAndHTTPLivenessProbe(context), @@ -338,7 +340,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceTCPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, }, }) @@ -363,7 +365,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceHTTPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithHTTPStartupProbe(context), @@ -372,7 +374,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceHTTPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, }, }) @@ -398,7 +400,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGRPCProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessProbe(context), @@ -407,7 +409,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGRPCProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, // The following test steps of gRPC startup probe are expected to fail with startup probe check failures. // This is because, due to the unavailability of ready-to-use container images of a gRPC service that @@ -460,6 +462,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceWithEmptyTCPStartupProbeAndHTTPLi resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -484,6 +487,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithTCPStartupProbeAndHTTPL resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -528,6 +532,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithEmptyHTTPStartupProbe(c resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -546,6 +551,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithHTTPStartupProbe(contex resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -578,6 +584,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCLivenessProbe(co resource "google_cloud_run_v2_service" "default" { name ="%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -599,6 +606,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -623,6 +631,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCStartupProbe(con resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -644,6 +653,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCStartupProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -668,6 +678,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessAndStartupPro resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -713,7 +724,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithDirectVPCUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location"}, + ImportStateVerifyIgnore: []string{"name", "location", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceWithDirectVPCUpdate(context), @@ -722,7 +733,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithDirectVPCUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location"}, + ImportStateVerifyIgnore: []string{"name", "location", "deletion_protection"}, }, }, }) @@ -733,6 +744,7 @@ func testAccCloudRunV2Service_cloudRunServiceWithDirectVPC(context map[string]in resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { @@ -753,6 +765,7 @@ func testAccCloudRunV2Service_cloudRunServiceWithDirectVPCUpdate(context map[str resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { @@ -786,7 +799,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithCustomAudience(serviceName, "test_update"), @@ -795,7 +808,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithoutCustomAudience(serviceName), @@ -804,7 +817,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, }, }) @@ -815,6 +828,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithoutCustomAudience(service resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false template { containers { @@ -833,6 +847,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithCustomAudience(serviceNam resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false custom_audiences = ["%s"] template { @@ -905,6 +920,7 @@ provider "google" { resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false labels = { user_label = "foo" @@ -932,6 +948,7 @@ provider "google" { resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false labels = { user_label = "bar" @@ -967,7 +984,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithServiceMinInstances(t *testin ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceWithNoMinInstances(context), @@ -976,7 +993,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithServiceMinInstances(t *testin ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, }, @@ -989,6 +1006,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" @@ -1020,6 +1038,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" diff --git a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown index 4e886659ef41..ed8c9749cfb7 100644 --- a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown +++ b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown @@ -141,6 +141,17 @@ and then run `terraform apply` to apply the change. ## Resource: `google_cloud_run_v2_job` +### Job deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Job. In 6.0.0, existing jobs will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + ### retyped `containers.env` to SET from ARRAY Previously, `containers.env` was a list, making it order-dependent. It is now a set. @@ -149,6 +160,17 @@ If you were relying on accessing an individual environment variable by index (fo ## Resource: `google_cloud_run_v2_service` +### Service deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Service. In 6.0.0, existing services will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + ### `liveness_probe` no longer defaults from API Cloud Run does not provide a default value for liveness probe. Now removing this field