gce_vm_deletion_protection: Toggle deletion protection for existing instances

Description Usage Arguments Examples

View source: R/deletion-prevention.R

Description

Toggle deletion protection for existing instances

Usage

1
2
3
4
5
6
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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 Jan. 23, 2022, 8:30 a.m.