Bitzu

Associate Cloud Engineer ยท Compute Engine: choosing, launching and scaling

Launching a VM with gcloud

gcloud compute instances create basics, machine families, availability policy (on host maintenance, automatic restart), SSH keys and metadata, service account and scopes at creation, startup scripts.

Key points

  • gcloud compute instances create NAME sets the zone and machine type.
  • At creation you also choose the availability policy (on host maintenance: MIGRATE or TERMINATE; automatic restart on or off), the service account and its access scopes, metadata such as SSH keys, and a startup script supplied through the startup-script metadata key.

Practice questions

Single choice

Which metadata key makes a Linux VM run a script every time it boots?

  1. boot-script
  2. startup-script
  3. init-script
  4. user-data
Show answer

Answer: B. startup-script

The startup-script key holds the script text (or startup-script-url a Cloud Storage location). The other names are not recognized by Compute Engine.

Select all that apply

Which of these can you configure when creating a VM?

  1. The service account the VM runs as
  2. A startup script passed through metadata
  3. A machine type that spans two zones
  4. A multi-region location for the VM
  5. A Local SSD as the boot disk
Show answer

Answer: A. The service account the VM runs as, B. A startup script passed through metadata

You pick the attached service account (with scopes) and can pass a startup script as metadata. A VM lives in one zone, and a boot disk cannot be Local SSD.

True or false

True or false: automatic restart will bring a VM back up after you stop it yourself from the console.

Show answer

Answer: False

False. Automatic restart applies to terminations Compute Engine initiates, such as a crash or host error, not to a stop you ordered.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module