A developer wants a 2nd-generation Cloud Function to run each time an object is created or deleted in a Cloud Storage bucket. Which trigger mechanism should the function be deployed with?
Show answer and explanation
Answer: D
Second-generation Cloud Functions use Eventarc to route events from Google Cloud sources. Choosing a Cloud Storage event type such as object finalize or object delete makes the function fire on those bucket changes. HTTP triggers handle web requests and do not receive storage notifications. Scheduler jobs run on a timetable rather than in response to changes, and a topic fed by hand would never carry storage events.
Why the other options are wrong
- A. Cloud Storage does not call arbitrary webhooks. HTTP-triggered functions only respond to requests sent directly to their URL.
- B. Polling runs on a timetable and may delay or miss changes. Scheduler triggers do not respond to object events at all.
- C. A topic that only receives manual messages would never get storage notifications unless something else publishes them. That is not an Eventarc-based trigger.