A cloud security engineer is tasking a DevOps team with deploying an automated monitoring agent on a new Google Compute Engine VM instance. The deployment must strictly adhere to Google Cloud security best practices of least privilege and secure service account management. Arrange the following administrative gcloud CLI and IAM setup steps in the correct operational sequence required to create, configure, delegate access for, and attach the custom service account.
- 1Create a dedicated custom service account using `gcloud iam service-accounts create ops-monitor-sa --display-name="Ops Monitor SA"`.
- 2Grant the required metric writing predefined role to the service account at the project level using `gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:ops-monitor-sa@PROJECT_ID.iam.gserviceaccount.com" --role="roles/monitoring.metricWriter"`.
- 3Grant the `roles/iam.serviceAccountUser` role on the service account resource to the DevOps engineer's identity using `gcloud iam service-accounts add-iam-policy-binding ops-monitor-sa@PROJECT_ID.iam.gserviceaccount.com --member="user:[email protected]" --role="roles/iam.serviceAccountUser"`.
- 4Deploy the Compute Engine instance attaching the customized service account using `gcloud compute instances create monitor-vm --zone=us-central1-a --service-account=ops-monitor-sa@PROJECT_ID.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/monitoring.write`.
Cevap
The correct sequence is: First, create the custom service account using `gcloud iam service-accounts create`. Second, assign the predefined role (`roles/monitoring.metricWriter`) to the service account at the project level using `gcloud projects add-iam-policy-binding`. Third, grant the provisioning user the `roles/iam.serviceAccountUser` role directly on the service account via `gcloud iam service-accounts add-iam-policy-binding`. Fourth, create the Compute Engine VM instance specifying `--service-account` with the service account email via `gcloud compute instances create`.
Provisioning a secure Compute Engine workload requires establishing the service account identity first (`gcloud iam service-accounts create`). Next, granting least-privilege predefined permissions to the service account (`gcloud projects add-iam-policy-binding`) establishes what the workload can do. Then, authorizing the deploying user to use the service account (`roles/iam.serviceAccountUser` via `gcloud iam service-accounts add-iam-policy-binding`) allows resource attachment. Finally, initiating VM creation with `--service-account` attaches the identity to the instance.
Adım Adım Çözüm
Anahtar Kavram
Creating and attaching custom service accounts to Compute Engine instances following least-privilege IAM configuration and ServiceAccountUser role delegation.
Tahmini Süre:2m 0s