An engineer needs to configure a `gcloud` command to deploy a Compute Engine virtual machine named `batch-processor` in zone `us-central1-a`. The VM must run using a dedicated custom service account named `[email protected]` and must automatically execute a script stored on the local administrative machine named `setup.sh` upon first boot. Which of the following flags must be included in the `gcloud compute instances create` command? (Select TWO correct answers.)
- [email protected]Answer
- --metadata-from-file=startup-script=setup.shAnswer
- C
- D--metadata=startup-script-url=setup.sh
Answer
The command requires `[email protected]` to attach the identity of the custom service account, and `--metadata-from-file=startup-script=setup.sh` to read and upload the local bash script as the startup script.
To assign a custom service account identity and execute a local script file on startup, `gcloud compute instances create` requires `--service-account` to define the identity and `--metadata-from-file=startup-script=...` to load local file contents into the startup script metadata entry.
Step-by-Step Solution
Key Concept
Deploying Compute Engine VMs with custom service accounts and local startup scripts via gcloud CLI
Estimated Time:1m 30s