Google Professional Cloud Developer Question 352
Single answerGoogle Cloud PlatformYou are developing a serverless application that processes images uploaded to a Cloud Storage bucket. You want to trigger an event-driven function to process the image whenever a new file is uploaded to the bucket. Which solution should you use to configure the event receiver?
- A
Use Eventarc to create a trigger for the Cloud Storage bucket and route events to the Cloud Function.
- B
Use Cloud Scheduler to periodically check for new files in the Cloud Storage bucket and invoke the Cloud Function.
- C
Use Pub/Sub to directly subscribe to Cloud Storage events and forward the events to the Cloud Function.
- D
Manually poll the Cloud Storage bucket for changes using a custom script and invoke the Cloud Function.
Show answer and explanation
Correct answer: A
Explanation
The best solution to trigger an event-driven function for processing new files uploaded to a Cloud Storage bucket is to use Eventarc. Eventarc is designed to listen to events from various Google Cloud services, including Cloud Storage, and route them to predefined destinations such as Cloud Functions. This eliminates the need for manual polling or scheduled tasks, ensuring efficient and real-time processing of events.
- A. Correct.
This is the correct answer. Eventarc can be configured to listen to events from Cloud Storage and route them to a Cloud Function, making it an ideal solution for event-driven architectures.
- B. Incorrect.
This is incorrect. Cloud Scheduler is designed for scheduled tasks, not for real-time event-driven processing of new files.
- C. Incorrect.
This is incorrect. Pub/Sub cannot directly subscribe to Cloud Storage events. Eventarc or Cloud Functions must be used to connect Cloud Storage events to Pub/Sub.
- D. Incorrect.
This is incorrect. Manually polling a Cloud Storage bucket for changes is inefficient and does not utilize event-driven architecture.