
Google Professional Cloud Developer
Get started today
Ultimate access to all questions.
You have two Google Cloud projects, named Project A and Project B. You need to deploy a Cloud Function in Project A that stores its output in a Cloud Storage bucket located in Project B while adhering to the principle of least privilege. How should you configure this setup?
You have two Google Cloud projects, named Project A and Project B. You need to deploy a Cloud Function in Project A that stores its output in a Cloud Storage bucket located in Project B while adhering to the principle of least privilege. How should you configure this setup?
Exam-Like
Explanation:
The principle of least privilege requires granting only the necessary permissions. To enable a Cloud Function in Project A to write to a bucket in Project B, the function must use a service account from Project A (its own project) with the minimal role roles/storage.objectCreator
assigned on the bucket in Project B.
- Option A incorrectly creates the service account in Project B, which cannot be used directly by the Cloud Function in Project A (service accounts are project-specific).
- Option B correctly creates a service account in Project A, deploys the function with it, and grants the required role on Project B's bucket, adhering to least privilege.
- Option C uses Project A's default App Engine service account, which has broad permissions (Editor role by default), violating least privilege.
- Option D uses Project B's default App Engine service account, which is invalid since the function in Project A cannot use a service account from another project without explicit impersonation setup (not mentioned here).