Question

Difficulty: MediumDeploying and Managing Compute Engine Virtual Machines

A cloud engineer needs to deploy a mission-critical database virtual machine named `prod-db-01` in zone `us-east4-a` using the `gcloud` CLI. To protect the workload against accidental deletion through the Google Cloud Console or CLI, deletion protection must be enabled on the instance. Furthermore, the boot disk must be retained if the VM is ever deleted in the future. Which `gcloud compute instances create` command should the engineer execute?

  1. gcloud compute instances create prod-db-01 --zone=us-east4-a --deletion-protection --no-auto-delete-boot-diskAnswer
  2. B
    gcloud compute instances create prod-db-01 --zone=us-east4-a --prevent-destroy --auto-delete-boot-disk=false
  3. C
    gcloud compute instances create prod-db-01 --zone=us-east4-a --provisioning-model=SPOT --no-auto-delete-boot-disk
  4. D
    gcloud compute instances create prod-db-01 --zone=us-east4-a --deletion-protection --scopes=roles/owner

Answer

The command using `gcloud compute instances create prod-db-01 --zone=us-east4-a --deletion-protection --no-auto-delete-boot-disk` correctly enables deletion protection and ensures the boot disk is preserved.
The correct command specifies `--deletion-protection` to guard the instance against accidental removal API calls and `--no-auto-delete-boot-disk` to preserve the persistent boot disk if the instance is eventually deleted.

Step-by-Step Solution

1
Identify the requirement for protecting the VM instance against accidental deletion
Determine that the official `gcloud` flag for instance deletion safety is `--deletion-protection`.
This flag prevents users from deleting the instance unless deletion protection is explicitly disabled first.
2
Identify the requirement for boot disk retention upon VM deletion
Determine that the official `gcloud` flag to override default boot disk auto-deletion is `--no-auto-delete-boot-disk`.
By default, persistent boot disks created during instance deployment are set to auto-delete when the VM is destroyed unless this flag is passed.
3
Evaluate and select the complete `gcloud compute instances create` command
Combine `--zone=us-east4-a`, `--deletion-protection`, and `--no-auto-delete-boot-disk` into the command invocation.
This combination fulfills all operational security and storage persistence constraints.

Key Concept

Compute Engine gcloud flags for deletion protection and boot disk retention policy
Rate this question