gce_vm_deletion_protection: Toggle deletion protection for existing instances

View source: R/deletion-prevention.R

gce_vm_deletion_protectionR Documentation

Toggle deletion protection for existing instances

Description

Toggle deletion protection for existing instances

Usage

gce_vm_deletion_protection(
  instance,
  cmd = c("status", "true", "false"),
  project = gce_get_global_project(),
  zone = gce_get_global_zone()
)

Arguments

instance

The vm to work with its deletion protection

cmd

Whether to get the status, or toggle "true" or "false" on deletion protection for this VM

project

The projectId

zone

The zone

Examples


## Not run: 

# a workflow for deleting lots of VMs across zones that have deletion protection
zones <- gce_list_zones()
instances <- lapply(zones$name, function(x) gce_list_instances(zone = x))

instances_e <- lapply(instances, function(x) x$items$name)
names(instances_e) <- zones$name

status <- lapply(zones$name, function(x){
  lapply(instances_e[[x]], function(y) {
    gce_vm_deletion_protection(y, cmd = "false", zone = x)))
    }
  }

deletes <- lapply(zones$name, function(x){
  lapply(instances_e[[x]], function(y) {
    gce_vm_delete(y, zone = x)))
    }
  }

## End(Not run)

cloudyr/googleComputeEngineR documentation built on June 11, 2025, 8:47 a.m.