An engineering team runs an automated batch processing pipeline on a Compute Engine virtual machine residing in `project-analytics`. The script needs to read raw log files stored in a Cloud Storage bucket inside `project-data`. Following Google Cloud security best practices for least privilege and identity management, which approach should be taken to grant the VM access to the storage bucket?
- Create a dedicated service account in `project-analytics`, grant it the Storage Object Viewer role (`roles/storage.objectViewer`) on the target bucket in `project-data`, and attach this service account to the VM instance.Cevap
- BCreate a dedicated service account in `project-analytics`, generate a downloadable JSON service account key file, and store it on the VM instance's local persistent disk for application authentication.
- CCreate a dedicated service account in `project-analytics`, grant it the Editor primitive role (`roles/editor`) at the project level on `project-data`, and attach this service account to the VM instance.
- DGrant the default Compute Engine service account the Viewer role at the organization level so that permissions inherit across all projects within the resource hierarchy.
Cevap
Create a dedicated service account in the source project (`project-analytics`), assign it the predefined `roles/storage.objectViewer` role scoped to the target bucket in `project-data`, and attach the service account to the Compute Engine VM instance.
The correct response adheres to Google Cloud security best practices by creating a dedicated user-managed service account, assigning only the minimum required predefined role (`roles/storage.objectViewer`) directly on the Cloud Storage bucket resource in the destination project, and attaching the service account directly to the Compute Engine VM. This avoids using exported service account keys while strictly enforcing least privilege.
Adım Adım Çözüm
Anahtar Kavram
Cross-Project Service Account Access and IAM Least Privilege Best Practices
Tahmini Süre:1m 30s