mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-05 17:52:38 +00:00
Add deletion_protection wrapper for deleting instance (#1211)
This commit is contained in:
parent
dd79754059
commit
8ada4ffdb2
|
@ -1495,6 +1495,10 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
|
|||
return err
|
||||
}
|
||||
log.Printf("[INFO] Requesting instance deletion: %s", d.Id())
|
||||
|
||||
if d.Get("deletion_protection").(bool) {
|
||||
return fmt.Errorf("Cannot delete instance %s: instance Deletion Protection is enabled. Set deletion_protection to false for this resource and run \"terraform apply\" before attempting to delete it.", d.Id())
|
||||
} else {
|
||||
op, err := config.clientCompute.Instances.Delete(project, zone, d.Id()).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting instance: %s", err)
|
||||
|
@ -1509,6 +1513,7 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
|
|||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func resourceComputeInstanceImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
parts := strings.Split(d.Id(), "/")
|
||||
|
|
|
@ -91,6 +91,7 @@ The following arguments are supported:
|
|||
* `description` - (Optional) A brief description of this resource.
|
||||
|
||||
* `deletion_protection` - (Optional) Enable deletion protection on this instance. Defaults to false.
|
||||
**Note:** you must disable deletion protection before removing the resource (e.g., via `terraform destroy`), or the instance cannot be deleted and the Terraform run will not complete successfully.
|
||||
|
||||
* `guest_accelerator` - (Optional) List of the type and count of accelerator cards attached to the instance. Structure documented below.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user