A Cloud Function needs access to other GCP resources. To enforce least privilege, what IAM/service-account setup should you use?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a new service account that has a custom IAM role to access the resources. The deployer is given permission to act as the new service account..
Why this is the answer
The correct approach for least privilege is to create a new service account with a custom IAM role. This role should only grant the specific permissions needed for the Cloud Function to interact with other GCP resources, avoiding broad roles like "Editor" which violate the principle of least privilege. The deployer then needs the iam.serviceAccounts.actAs permission on this new service account. This allows the deployer to deploy the Cloud Function using the new service account's identity, ensuring the function runs with only the necessary permissions. Granting permission to "get the access token" is less secure and not the standard way to assign service account identity to a Cloud Function.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed