Question

Difficulty: EasyDeploying and Managing Compute Engine Virtual Machines

A cloud engineer needs to launch a Compute Engine VM instance named `app-server` into a custom Virtual Private Cloud subnet named `backend-subnet`. Which `gcloud compute instances create` command flag must be used to place the VM directly into this target subnet?

  1. --subnet=backend-subnetAnswer
  2. B
    --network-tier=backend-subnet
  3. C
    --vpc-zone=backend-subnet
  4. D
    --address=backend-subnet

Answer

Use the `--subnet=backend-subnet` flag with `gcloud compute instances create` to deploy the virtual machine into a specific VPC subnet.
The `--subnet` flag in `gcloud compute instances create` specifies the subnetwork to which the primary network interface of the new VM instance should be attached.

Step-by-Step Solution

1
Identify the target resource requirement from the prompt.
The requirement specifies deploying a Compute Engine VM into a custom VPC subnet named `backend-subnet`.
When creating virtual machines in non-default VPC networks, the network interface must be explicitly bound to the intended subnet.
2
Evaluate the Google Cloud CLI (`gcloud compute instances create`) flag syntax.
The standard flag to specify a subnetwork for the instance is `--subnet` (or `--subnet=SUBNET_NAME`).
Using correct command-line flags ensures the instance network interface attaches to the specified subnet during creation.

Key Concept

Compute Engine VM Networking Flags in gcloud CLI
Rate this question