Google Professional Cloud Developer Question 353
Single answerGoogle Cloud PlatformYou are developing a serverless application and need to configure an event-driven architecture. Your application must trigger a Cloud Run service whenever a file is uploaded to a specific Cloud Storage bucket. Which approach should you take to meet this requirement?
- A
Create a Pub/Sub topic, configure Cloud Storage to publish upload events to the topic, and configure Cloud Run to subscribe to the topic.
- B
Use Eventarc to directly route Cloud Storage upload events to the Cloud Run service.
- C
Configure a Cloud Function to listen to Cloud Storage upload events and invoke the Cloud Run service.
- D
Set up a cron job in Cloud Scheduler to periodically check the Cloud Storage bucket and invoke the Cloud Run service.
Show answer and explanation
Correct answer: B
Explanation
Eventarc is the recommended solution for configuring event receivers in an event-driven architecture. It provides native integration with Cloud Storage and can directly route events to Cloud Run services without needing additional intermediaries. This reduces complexity and ensures efficient, real-time event handling.
- A. Incorrect.
While Pub/Sub can be used for event-driven architectures, this approach requires additional configuration and is not the most direct solution when Eventarc supports Cloud Storage events natively.
- B. Correct.
Eventarc supports direct integration with Cloud Storage for specific events, such as file uploads. It can natively trigger Cloud Run services, making it the most efficient and recommended solution.
- C. Incorrect.
Using a Cloud Function to listen to Cloud Storage events and invoke Cloud Run adds unnecessary complexity and is not recommended when Eventarc natively supports the use case.
- D. Incorrect.
Using a cron job to periodically check the bucket for changes is inefficient and not event-driven, which does not align with the requirements of the problem.