Skip to content

Commit

Permalink
Add deletion_protection field in cloudvmcluster resource (GoogleCloud…
Browse files Browse the repository at this point in the history
  • Loading branch information
tulika-aakriti authored and amanMahendroo committed Dec 17, 2024
1 parent a47d866 commit 4f35372
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mmv1/products/oracledatabase/CloudVmCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ async:
error:
path: 'error'
message: 'message'
custom_code:
pre_delete: 'templates/terraform/pre_delete/oracledatabase_cloud_vmcluster.go.tmpl'
examples:
- name: 'oracledatabase_cloud_vmcluster_basic'
primary_resource_id: 'my_vmcluster'
vars:
project: 'my-project'
cloud_vm_cluster_id: 'my-instance'
cloud_exadata_infrastructure_id: 'my-exadata'
deletion_protection: 'true'
ignore_read_extra:
- 'deletion_protection'
test_vars_overrides:
'deletion_protection': 'false'
'project': '"oci-terraform-testing"'
'cloud_vm_cluster_id': '"ofake-vmcluster-basic"'
'cloud_exadata_infrastructure_id': '"ofake-exadata-for-vm-basic"'
Expand All @@ -66,10 +72,21 @@ examples:
project: 'my-project'
cloud_vm_cluster_id: 'my-instance'
cloud_exadata_infrastructure_id: 'my-exadata'
deletion_protection: 'true'
ignore_read_extra:
- 'deletion_protection'
test_vars_overrides:
'deletion_protection': 'false'
'project': '"oci-terraform-testing"'
'cloud_vm_cluster_id': '"ofake-vmcluster-full"'
'cloud_exadata_infrastructure_id': '"ofake-exadata-for-vm-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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ resource "google_oracle_database_cloud_vm_cluster" "{{$.PrimaryResourceId}}"{
gi_version = "19.0.0.0"
hostname_prefix = "hostname1"
}

deletion_protection = "{{index $.Vars "deletion_protection"}}"
}

resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfrastructures"{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ resource "google_oracle_database_cloud_vm_cluster" "{{$.PrimaryResourceId}}"{
}
memory_size_gb = 60
}

deletion_protection = "{{index $.Vars "deletion_protection"}}"
}

resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfrastructures"{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if d.Get("deletion_protection").(bool) {
return fmt.Errorf("cannot destroy google_oracle_database_cloud_vm_cluster resource with id : %q without setting deletion_protection=false and running `terraform apply`", d.Id())
}

0 comments on commit 4f35372

Please sign in to comment.