Soru

Zorluk: OrtaDeploying and Managing Compute Engine Virtual Machines

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.)

  1. --metadata-from-file=startup-script=./scripts/setup-worker.shCevap
  2. [email protected] --scopes=https://www.googleapis.com/auth/cloud-platformCevap
  3. C
    --metadata=startup-script=./scripts/setup-worker.sh
  4. 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

1
Identify the flag required to pass a local file script to Compute Engine metadata.
Determine that `--metadata-from-file` must be used with the key `startup-script` so that `gcloud` reads the contents of `./scripts/setup-worker.sh` during command execution.
Using standard `--metadata` passes the literal string path rather than the script file contents.
2
Identify the flags required to attach a custom service account and define API access scopes.
Determine that `--service-account` specifies the service account email address, while `--scopes=https://www.googleapis.com/auth/cloud-platform` grants access across Google Cloud services.
Compute Engine instance creation uses `--service-account` rather than `--iam-account`.

Anahtar Kavram

Compute Engine gcloud CLI Instance Provisioning Flags
Bu soruyu puanla