A company is migrating an internal analytics service to Compute Engine. The service needs to run on a dedicated custom Virtual Machine instance named `analytics-worker` in the custom subnet `prod-analytics-subnet` within VPC `prod-vpc`. The VM must authenticate to Google Cloud services using a dedicated user-managed service account `[email protected]` with full access to Cloud Storage API scopes. Additionally, the instance must be provisioned without a public IP address to satisfy strict corporate security policies. Which `gcloud` command correctly provisions this Compute Engine Virtual Machine instance according to these requirements?
- gcloud compute instances create analytics-worker --zone=us-central1-a --subnet=prod-analytics-subnet --no-address --service-account=analytics-sa@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_controlAnswer
- Bgcloud compute instances create analytics-worker --zone=us-central1-a --network=prod-vpc --public-ip=false --roles=roles/storage.admin --service-account=analytics-sa@my-project.iam.gserviceaccount.com
- Cgcloud compute instances create analytics-worker --zone=us-central1-a --subnet=prod-analytics-subnet --no-address --provisioning-model=SPOT --instance-termination-action=STOP --service-account=analytics-sa@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_control
- Dgcloud compute instances create analytics-worker --zone=us-central1-a --subnet=prod-analytics-subnet --no-address --scopes=roles/owner
Answer
The command using `--subnet=prod-analytics-subnet --no-address --service-account=analytics-sa@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_control` correctly provisions the instance.
The correct option correctly uses `gcloud compute instances create` parameters: `--subnet` to specify the custom VPC subnet, `--no-address` to omit an external IP address, `--service-account` to attach the custom service account email, and `--scopes` to define the API access scope for Cloud Storage.
Step-by-Step Solution
Key Concept
Deploying Compute Engine Virtual Machines with Custom Subnets, Private IPs, and Service Accounts via gcloud CLI
Estimated Time:2m 0s