Stay organized with collections Save and categorize content based on your preferences.

Cloud Functions triggers

You can set up Cloud Functions to execute in response to various scenarios by specifying a trigger for your function. Triggers can be HTTP(S) requests or one of a number of supported events. This page provides an overview of the triggers supported by Cloud Functions.

Broadly, triggers fall into two categories:

  • HTTP triggers, which react to HTTP(S) requests, and correspond to HTTP functions.

  • Event triggers, which react to events within your Google Cloud project, and correspond to event-driven functions.

You specify triggers as part of function deployment. You cannot bind the same function to more than one trigger at a time, but you can have the same event cause multiple functions to execute by deploying multiple functions with the same trigger settings.

Triggers supported in Cloud Functions (2nd gen)

Cloud Functions (2nd gen) supports the following types of triggers:

All event-driven functions in Cloud Functions (2nd gen) use Eventarc for event delivery. In Cloud Functions (2nd gen), Pub/Sub triggers and Cloud Storage triggers are implemented as particular types of Eventarc triggers.

Triggers supported in Cloud Functions (1st gen)

Cloud Functions (1st gen) supports the following types of triggers:

Additional triggers via Pub/Sub and webhooks

Because Cloud Functions can be triggered by messages on a Pub/Sub topic, you can integrate Cloud Functions with any other Google service that supports Pub/Sub as an event bus. In addition, by using HTTP triggers you can also integrate with any service that provides HTTP callbacks (webhooks). The following sections describe some example integrations.

Cloud Logging

Cloud Logging can route logs to a Pub/Sub topic, where they can then be consumed by Cloud Functions. See Configure and manage sinks in the Cloud Logging documentation for more information.

Cloud Scheduler

Cloud Scheduler jobs can send messages to a Pub/Sub topic, where they can then be consumed by Cloud Functions. See the Cloud Scheduler tutorial Using Pub/Sub to trigger a Cloud Function for more information.

Cloud Tasks

Cloud Tasks HTTP Target tasks enable you to run task handlers at any HTTP endpoint, so a Cloud Function with an HTTP trigger can be used as a task handler. You can also use tasks to throttle or rate-limit function invocations. See Create HTTP Target tasks in the Cloud Tasks documentation for more information.

Gmail

Using the Gmail Push Notification API, you can send Gmail events to a Pub/Sub topic and consume them with Cloud Functions.