Question

Difficulty: EasyDeploying and Managing Compute Engine Virtual Machines

A cloud engineer needs to deploy a new Compute Engine virtual machine instance using the Google Cloud CLI. The deployment requires configuring custom startup scripts and instance metadata key-value pairs. Which of the following gcloud command flags can be validly used with 'gcloud compute instances create' to accomplish this? (Select TWO correct responses.)

  1. --metadata-from-fileAnswer
  2. --metadataAnswer
  3. C
    --scopes-from-file
  4. D
    --preemptible-always-on

Answer

The correct options are '--metadata-from-file' and '--metadata'.
When creating a Compute Engine VM instance using 'gcloud compute instances create', custom metadata key-value pairs are passed using the '--metadata' flag, and files (such as startup scripts) are passed into metadata using the '--metadata-from-file' flag.

Step-by-Step Solution

1
Identify the required parameters for attaching custom metadata and startup script files when creating a VM with gcloud.
Determine that metadata can be attached inline or read from a local file path.
Compute Engine uses instance metadata keys such as 'startup-script' or custom keys for configuration during initialization.
2
Evaluate the valid gcloud compute instances create flags.
Select '--metadata' for inline key-value pairs and '--metadata-from-file' for supplying script content from local files.
Both flags are standard parameters in the gcloud CLI tool for Compute Engine VM provisioning.

Key Concept

Deploying Compute Engine instances using gcloud CLI metadata flags
Rate this question