Question

Difficulty: MediumCreating and Managing Service Accounts

A cloud engineering team is deploying an automated data ingestion workload on Compute Engine virtual machine instances in a staging project. The workload must read source files from Google Cloud Storage buckets located in a separate production analytics project. Following Google Cloud security best practices for managing service accounts and IAM access, which two configuration steps should the team perform? (Select TWO.)

  1. Create a user-managed service account in the staging project and attach it to the Compute Engine VM instances.Answer
  2. Grant the service account the predefined Storage Object Viewer role on the specific Cloud Storage buckets in the production project.Answer
  3. C
    Generate a service account JSON key file and upload it to the Compute Engine VM disk to authenticate Cloud Storage API calls.
  4. D
    Grant the service account the primitive Editor role at the project level across both staging and production projects.
  5. E
    Assign the Storage Admin role to the service account at the organization level, expecting resource-level restrictions in child projects to restrict access.

Answer

The correct steps are to create a user-managed service account in the staging project, attach it to the Compute Engine VM instances, and grant that service account the predefined Storage Object Viewer role directly on the production Cloud Storage buckets.
The correct configuration requires creating a dedicated user-managed service account in the staging project housing the Compute Engine VMs and attaching it directly to the instances. Access to the external production Cloud Storage buckets is provided by granting the service account the specific predefined Storage Object Viewer role on those buckets, ensuring least privilege and secure credential management via instance metadata.

Step-by-Step Solution

1
Identify workload identity requirement
Determine that Compute Engine VMs should run under a dedicated user-managed service account configured in their hosting project.
Attaching a service account to a VM allows Google Cloud to provide application default credentials via instance metadata, avoiding manual key management.
2
Configure cross-project least-privilege IAM permissions
Grant the Storage Object Viewer role to the staging service account on the production storage buckets.
IAM roles can be granted across project boundaries to service account principals. Using predefined read-only roles on specific buckets enforces the principle of least privilege.

Key Concept

Best practices for creating user-managed service accounts, attaching them to Compute Engine workloads, and configuring cross-project IAM access using least privilege without service account keys.
Rate this question