Question

Difficulty: MediumDeploying Serverless Applications with Cloud Run and Cloud Functions

A DevOps team is deploying an event-driven Python microservice as a Cloud Functions (2nd gen) service to process file uploads arriving in a Cloud Storage bucket. The microservice must execute using a dedicated custom service account under the principle of least privilege while interacting with Cloud Storage and Firestore. Which TWO actions must the team perform to successfully deploy and configure this serverless workload?

  1. Pass the custom service account email address using the `--service-account` flag when executing the `gcloud functions deploy` command.Answer
  2. Grant the `roles/eventarc.eventReceiver` IAM role to the runtime service account to allow it to receive trigger events.Answer
  3. C
    Assign the primitive `roles/editor` role to the default Compute Engine service account to streamline Cloud Storage and Firestore access.
  4. D
    Enable the Cloud Functions and Eventarc APIs at the Google Cloud Organization resource node rather than within the individual target project.

Answer

The team must pass the custom service account email via the `--service-account` flag during deployment and grant the `roles/eventarc.eventReceiver` IAM role to the runtime service account.
Deploying a 2nd gen Cloud Function with Cloud Storage triggers requires specifying the custom service account via `--service-account` during `gcloud functions deploy` and granting `roles/eventarc.eventReceiver` to that service account so it can receive incoming trigger events.

Step-by-Step Solution

1
Configure the runtime service account identity for the function.
Using the `--service-account` flag during `gcloud functions deploy` ensures the function executes with the specific custom identity instead of the default service account.
This enforces least privilege by granting only necessary predefined roles to Cloud Storage and Firestore.
2
Configure Eventarc trigger permissions for 2nd gen Cloud Functions.
Granting `roles/eventarc.eventReceiver` to the runtime service account allows it to receive Storage events routed via Eventarc.
2nd gen Cloud Functions rely on Eventarc infrastructure to deliver Cloud Storage event notifications.

Key Concept

Deploying 2nd gen Cloud Functions with custom service accounts and Eventarc triggers
Rate this question