A DevOps team is writing a script to automate the deployment of stateless worker virtual machines using the Google Cloud CLI. The Compute Engine instances must meet two specific operational requirements:
1. Execute a local bash script located at `./scripts/setup-worker.sh` during the initial instance startup.
2. Run under a custom service account named `[email protected]` while explicitly granting the instance full access to all Google Cloud APIs.
Which flag configurations should be included in the `gcloud compute instances create` command to satisfy these requirements? (Select TWO options.)
- --metadata-from-file=startup-script=./scripts/setup-worker.shCevap
- [email protected] --scopes=https://www.googleapis.com/auth/cloud-platformCevap
- C--metadata=startup-script=./scripts/setup-worker.sh
- D
Cevap
The correct configurations are using '--metadata-from-file=startup-script=./scripts/setup-worker.sh' to load the local script into metadata, and '[email protected] --scopes=https://www.googleapis.com/auth/cloud-platform' to attach the custom identity with full Cloud Platform API scope.
To provision a Compute Engine instance with a local startup script, `--metadata-from-file=startup-script=<path>` is required because it reads the local script file and sends its content to the instance metadata server. Additionally, attaching a custom identity and enabling full service access requires `--service-account=<email>` combined with `--scopes=https://www.googleapis.com/auth/cloud-platform`.
Adım Adım Çözüm
Anahtar Kavram
Compute Engine gcloud CLI Instance Provisioning Flags