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
Which metadata key makes a Linux VM run a script every time it boots?
- boot-script
- startup-script
- init-script
- 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.
Which of these can you configure when creating a VM?
- The service account the VM runs as
- A startup script passed through metadata
- A machine type that spans two zones
- A multi-region location for the VM
- 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: 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.
