A DevOps team is bootstrapping CI/CD pipelines that need access to API keys stored in Secret Manager. The pipelines run on Cloud Build. What is the best practice for granting access to secrets?
This provides least-privilege access to secrets.
Why this answer
Granting the Cloud Build service account the roles/secretmanager.secretAccessor role on the project containing secrets follows the principle of least privilege. Option A is wrong because using a custom service account with roles/secretmanager.admin grants excessive permissions. Option B is wrong because storing API keys as build substitutions is insecure and exposes them in logs.
Option D is wrong because Cloud KMS is used for encryption, not as a best practice for secret access.