An organization runs an automated database maintenance script on a Compute Engine virtual machine located in project `prod-workloads`. The script needs to retrieve a database password stored in Google Cloud Secret Manager within project `prod-secrets`. Company security policies strictly prohibit the creation and management of downloadable service account JSON keys. Which access management configuration follows Google-recommended best practices to allow the workload to authenticate while enforcing least privilege?
- Attach a dedicated service account to the Compute Engine instance in `prod-workloads` and grant that service account the Secret Manager Secret Accessor role (`roles/secretmanager.secretAccessor`) on the specific secret resource in `prod-secrets`.Cevap
- BAttach a dedicated service account to the Compute Engine instance in `prod-workloads` and grant it the Service Account Admin role (`roles/iam.serviceAccountAdmin`) in `prod-secrets` so it can impersonate the secret owner service account.
- CAttach a dedicated service account to the Compute Engine instance in `prod-workloads` and grant it the Editor primitive role (`roles/editor`) at the project level on `prod-secrets`.
- DConfigure Secret Manager in `prod-secrets` to use Customer-Supplied Encryption Keys (CSEK) and store the raw cryptographic key file on the local boot disk of the Compute Engine instance.
Cevap
Attach a dedicated service account to the Compute Engine instance in `prod-workloads` and grant that service account the Secret Manager Secret Accessor role (`roles/secretmanager.secretAccessor`) on the specific secret resource in `prod-secrets`.
Attaching a dedicated service account to the VM instance allows the workload to automatically authenticate using Application Default Credentials (ADC) without requiring static JSON service account keys. Granting `roles/secretmanager.secretAccessor` directly on the targeted secret resource in the secret project enforces granular cross-project access following the principle of least privilege.
Adım Adım Çözüm
Anahtar Kavram
Cross-Project Secret Manager Access using Service Account Metadata and Resource-Level IAM Roles