Google Professional Cloud Developer Question 349
Select 3Google Cloud PlatformYou are developing a cloud-native application that processes file uploads to a Cloud Storage bucket. When a file is uploaded, the application should trigger a Cloud Run service for further processing. Which steps should you take to configure the event receiver correctly?
- A
Create an Eventarc trigger with the Cloud Storage bucket as the source and the Cloud Run service as the destination.
- B
Grant the 'roles/eventarc.eventReceiver' role to the Cloud Run service's service account.
- C
Enable the Eventarc, Cloud Run, and Cloud Storage APIs in your project.
- D
Set up a Pub/Sub topic and manually configure Cloud Run to subscribe to it.
- E
Add a filter to the Eventarc trigger to specify the storage event type, such as 'google.cloud.storage.object.v1.finalized'.
Show answer and explanation
Correct answers: A, C, E
Explanation
To configure an event receiver for processing file uploads to a Cloud Storage bucket with Cloud Run, you should use Eventarc to create a trigger that connects the bucket to the Cloud Run service. This approach eliminates the need for manual Pub/Sub subscriptions and simplifies the event-driven architecture. Additionally, enabling the relevant APIs is required for the services to function. Adding a filter to the Eventarc trigger ensures that only specific events (such as file finalization) are processed.
- A. Correct.
Correct: Creating an Eventarc trigger is the recommended way to connect a Cloud Storage bucket to a Cloud Run service for event-driven architectures.
- B. Incorrect.
Incorrect: The 'roles/eventarc.eventReceiver' role is not required for the Cloud Run service's service account in this scenario. Eventarc handles the event delivery.
- C. Correct.
Correct: Enabling the necessary APIs (Eventarc, Cloud Run, and Cloud Storage) is required for the services to interact correctly.
- D. Incorrect.
Incorrect: Manually setting up a Pub/Sub topic and configuring Cloud Run to subscribe is not necessary when using Eventarc, as it simplifies event delivery.
- E. Correct.
Correct: Adding a filter specifying the event type ensures that only the desired events (e.g., file finalization) trigger the Cloud Run service.