Events and Triggers

This page describes the concept of events in the context of Google Cloud Functions. It also covers how to create and associate triggers with functions so that they will execute when an event is fired. Finally, this page describes the schema for the most common event types.


Cloud events are things that happen within your cloud environment that you might want to take action on. These might be things like changes to data in a database, files added to a storage system, or a new virtual machine instance being created. Currently, Cloud Functions supports events from the following providers:

For examples of how to associate triggers with functions so that they will execute when an event is fired, see the tutorials.

Event Parameter and Data Property

The event parameter holds the data associated with the event that triggered the execution of the function along with metadata about the event itself. The event data is contained in a data property of the event:

Property Description Type
data The data object for the event. Object
context The context object for the event. Object
context.eventId A unique ID for the event. String
context.timestamp The date/time this event was created. String (ISO 8601)
context.eventType The type of the event. String
context.resource The resource that emitted the event. String

The actual data is contained in the property. Each event type has its own schema for the data property. Below is a list of current event types and their data payloads:


Creating a response to an event is done with a Trigger. A trigger is a declaration that you are interested in a certain event or set of events. Binding a function to a trigger allows you to capture and act on events.

Below is a table of the types of triggers supported and the flags used to specify them during command line deployment:

Resource Command line flag
HTTP --trigger-http
Google Cloud Storage --trigger-bucket [BUCKET NAME]
Google Cloud Pub/Sub --trigger-topic [TOPIC NAME]

Binding of triggers to functions happens at deployment time either via the CLI, the UI or Cloud Functions API. Functions and triggers are bound to each other on a many-to-one basis. In other words, you cannot bind the same function to more than a single trigger at a time. You can, however, have the same trigger cause multiple functions to execute by simply deploying two different functions with the same trigger.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Functions Documentation