Soru

Zorluk: OrtaCreating and Managing Service Accounts

A DevOps engineer is configuring a Python application running on a Compute Engine virtual machine in project `project-app`. The application must read log objects stored in a Cloud Storage bucket named `analytics-data-archive` located in project `project-data`. Following Google Cloud security best practices and the principle of least privilege, which TWO actions should be performed to configure access for the virtual machine?

  1. Attach a dedicated user-managed service account to the Compute Engine virtual machine instance.Cevap
  2. Grant the user-managed service account the Storage Object Viewer role (`roles/storage.objectViewer`) on the `analytics-data-archive` bucket.Cevap
  3. C
    Create a service account key in JSON format and store it in the application configuration directory on the virtual machine.
  4. D
    Grant the user-managed service account the primitive Editor role (`roles/editor`) at the `project-data` project level.
  5. E
    Grant the Compute Engine default service account the Storage Admin role (`roles/storage.admin`) at the Organization level so permissions inherit downwards.

Cevap

The correct configuration requires attaching a dedicated user-managed service account to the Compute Engine virtual machine and granting that service account the Storage Object Viewer role (`roles/storage.objectViewer`) directly on the specific Cloud Storage bucket.
Google Cloud security best practices dictate attaching a dedicated user-managed service account to the Compute Engine VM so that applications automatically authenticate via Application Default Credentials (ADC). Furthermore, applying the predefined Storage Object Viewer role (`roles/storage.objectViewer`) directly to the target bucket ensures cross-project access is granted strictly according to the principle of least privilege.

Adım Adım Çözüm

1
Create and attach a user-managed service account to the Compute Engine instance.
The application automatically leverages Application Default Credentials (ADC) via the metadata server without needing explicit service account keys.
Running workloads inside Google Cloud infrastructure should utilize attached service accounts rather than long-lived service account JSON keys.
2
Grant the service account `roles/storage.objectViewer` on `gs://analytics-data-archive`.
The service account gains read access exclusively to the objects inside the target bucket in the secondary project.
Applying predefined IAM roles at the resource level enforces the principle of least privilege.

Anahtar Kavram

Cross-project service account access using attached service accounts and least-privilege resource-level role bindings.
Bu soruyu puanla