An enterprise security architecture team requires all Compute Engine VM instances provisioned for a mission-critical web backend to use fine-grained IAM authorization. The instances must run under a custom IAM service account named `[email protected]` with restricted Cloud Pub/Sub permissions, and they must automatically run a bootstrapping script located at a private Cloud Storage path (`gs://config-bucket-prod/startup.sh`) during initialization. Which `gcloud` CLI command correctly creates an instance template meeting these security and operational requirements?
- gcloud compute instance-templates create backend-template --service-account=backend-service-sa@prod-proj.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform --metadata=startup-script-url=gs://config-bucket-prod/startup.shCevap
- Bgcloud compute instance-templates create backend-template --service-account=backend-service-sa@prod-proj.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/pubsub --metadata=startup-script=gs://config-bucket-prod/startup.sh
- Cgcloud compute instance-templates create backend-template --scopes=https://www.googleapis.com/auth/pubsub --metadata=startup-script-url=gs://config-bucket-prod/startup.sh
- Dgcloud compute instance-templates create backend-template --service-account=backend-service-sa@prod-proj.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform --metadata=startup-script-url=gs://config-bucket-prod/startup.sh --provisioning-model=SPOT --instance-termination-action=DELETE
Cevap
The command specifying `--service-account=backend-service-sa@prod-proj.iam.gserviceaccount.com`, `--scopes=https://www.googleapis.com/auth/cloud-platform`, and `--metadata=startup-script-url=gs://config-bucket-prod/startup.sh` correctly provisions the instance template according to Google Cloud security and CLI best practices.
The command configuring `--service-account` with the custom identity, setting the scope to `cloud-platform`, and defining `--metadata=startup-script-url=gs://...` follows all Google Cloud recommended practices. Setting the access scope to `cloud-platform` allows IAM roles attached to the custom service account to grant fine-grained permissions without being restricted by legacy OAuth access scope boundaries, while `startup-script-url` ensures Compute Engine correctly fetches the initialization script from Cloud Storage.
Adım Adım Çözüm
Anahtar Kavram
Configuring Compute Engine Instance Templates with custom IAM Service Accounts and Startup Script URIs via gcloud CLI