diff --git a/mmv1/products/oracledatabase/CloudExadataInfrastructure.yaml b/mmv1/products/oracledatabase/CloudExadataInfrastructure.yaml index 981e026aa0f7..97b5f8702707 100644 --- a/mmv1/products/oracledatabase/CloudExadataInfrastructure.yaml +++ b/mmv1/products/oracledatabase/CloudExadataInfrastructure.yaml @@ -48,23 +48,39 @@ async: path: 'error' message: 'message' custom_code: + pre_delete: 'templates/terraform/pre_delete/oracledatabase_cloud_exadata_infrastructure.go.tmpl' examples: - name: 'oracledatabase_cloud_exadata_infrastructure_basic' primary_resource_id: 'my-cloud-exadata' vars: project: 'my-project' cloud_exadata_infrastructure_id: 'my-instance' + deletion_protection: 'true' + ignore_read_extra: + - 'deletion_protection' test_vars_overrides: 'project': '"oci-terraform-testing"' + 'deletion_protection': 'false' 'cloud_exadata_infrastructure_id': '"ofake-exadata-basic"' - name: 'oracledatabase_cloud_exadata_infrastructure_full' primary_resource_id: 'my-cloud-exadata' vars: project: 'my-project' cloud_exadata_infrastructure_id: 'my-instance' + deletion_protection: 'true' + ignore_read_extra: + - 'deletion_protection' test_vars_overrides: 'project': '"oci-terraform-testing"' + 'deletion_protection': 'false' 'cloud_exadata_infrastructure_id': '"ofake-exadata-full"' +virtual_fields: + - name: 'deletion_protection' + type: Boolean + default_value: true + description: 'Whether or not to allow Terraform to destroy the instance. + Unless this field is set to false in Terraform state, a terraform destroy + or terraform apply that would delete the instance will fail.' parameters: - name: 'location' type: String diff --git a/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_basic.tf.tmpl b/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_basic.tf.tmpl index 69cddcfac019..5ff65d2362e4 100644 --- a/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_basic.tf.tmpl @@ -8,4 +8,6 @@ resource "google_oracle_database_cloud_exadata_infrastructure" "{{$.PrimaryResou compute_count= "2" storage_count= "3" } + + deletion_protection = "{{index $.Vars "deletion_protection"}}" } diff --git a/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_full.tf.tmpl b/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_full.tf.tmpl index d10f81f7f7ff..7de73ffeb800 100644 --- a/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/oracledatabase_cloud_exadata_infrastructure_full.tf.tmpl @@ -27,4 +27,6 @@ resource "google_oracle_database_cloud_exadata_infrastructure" "{{$.PrimaryResou labels = { "label-one" = "value-one" } + + deletion_protection = "{{index $.Vars "deletion_protection"}}" } diff --git a/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_basic.tf.tmpl b/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_basic.tf.tmpl index 7ac2edfa9301..a4a7e12f69c5 100644 --- a/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_basic.tf.tmpl @@ -28,6 +28,8 @@ resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfr compute_count= "2" storage_count= "3" } + + deletion_protection = "{{index $.Vars "deletion_protection"}}" } data "google_compute_network" "default" { diff --git a/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_full.tf.tmpl b/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_full.tf.tmpl index 3cfe225f6454..7547e02bfc70 100644 --- a/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/oracledatabase_cloud_vmcluster_full.tf.tmpl @@ -49,6 +49,8 @@ resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfr compute_count= "2" storage_count= "3" } + + deletion_protection = "{{index $.Vars "deletion_protection"}}" } data "google_compute_network" "default" { diff --git a/mmv1/templates/terraform/pre_delete/oracledatabase_cloud_exadata_infrastructure.go.tmpl b/mmv1/templates/terraform/pre_delete/oracledatabase_cloud_exadata_infrastructure.go.tmpl new file mode 100644 index 000000000000..3fe310fd1a2c --- /dev/null +++ b/mmv1/templates/terraform/pre_delete/oracledatabase_cloud_exadata_infrastructure.go.tmpl @@ -0,0 +1,3 @@ +if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy google_oracle_database_cloud_exadata_infrastructure resource with id : %q without setting deletion_protection=false and running `terraform apply`", d.Id()) +}