Question

Difficulty: EasyDeploying and Managing Compute Engine Virtual Machines

You need to deploy a new Compute Engine virtual machine instance named 'web-server' in the zone 'us-central1-a' using the Google Cloud CLI. Which gcloud command should you run?

  1. gcloud compute instances create web-server --zone=us-central1-aAnswer
  2. B
    gcloud compute instances create web-server --region=us-central1-a
  3. C
    gcloud compute vms create web-server --zone=us-central1-a
  4. D
    gcloud instances create web-server --zone=us-central1-a

Answer

The command 'gcloud compute instances create web-server --zone=us-central1-a' correctly deploys the VM instance to the specified zone.
To create a Compute Engine instance using the Google Cloud CLI, the command must target the 'gcloud compute instances create' resource path and pass the target zone using the '--zone' flag.

Step-by-Step Solution

1
Identify the gcloud command group for managing Compute Engine instances.
The correct command group is 'gcloud compute instances'.
Compute Engine resources fall under the 'compute' command group in gcloud CLI.
2
Specify the creation action and resource name.
Append 'create web-server'.
The 'create' subcommand provisions a new VM instance with the specified name.
3
Specify the target zonal location flag.
Append '--zone=us-central1-a'.
Compute Engine VM instances are zonal resources and require the '--zone' flag rather than '--region'.

Key Concept

Deploying Compute Engine Virtual Machines via gcloud CLI syntax
Rate this question