If you are creating a new function, see the Console Quickstart on Cloud Run. The content on this page only applies to existing legacy functions created with the Cloud Functions v1 API.
Stay organized with collections
Save and categorize content based on your preferences.
Cloud Storage triggers (1st gen)
In Cloud Run functions, a Cloud Storage trigger enables a function to be called
in response to changes in Cloud Storage. When you
specify a Cloud Storage trigger for a function, you choose an event
type and specify a Cloud Storage bucket. Your function will be called
whenever a change occurs on an object (file) within the specified bucket.
The following Cloud Storage event types are supported:
Event
Event type
Description
Object finalized
google.storage.object.finalize
Occurs when a new object is created, or an existing object is
overwritten and a new generation of that object is created.
Object deleted
google.storage.object.delete
Occurs when an object is soft deleted. For more information, see
Soft delete.
Object archived
google.storage.object.archive
Occurs when a live version of an object becomes a noncurrent version.
For more information, see
Object Versioning.
Object metadata updated
google.storage.object.metadataUpdate
Occurs when the metadata of an
existing object changes.
For a function to use a Cloud Storage trigger, it must be implemented as an
event-driven function:
The
Google Events
repository contains additional resources for working with event data.
Deployment
You can specify a Cloud Storage trigger when you deploy a function. See
Deploy a Cloud Run function for
general instructions on how to deploy a function, and see the following for
additional information specific to configuring Cloud Storage triggers
during deployment.
gcloud
If you are
deploying using the gcloud CLI,
you can use the Cloud Storage Object finalized event type with the
following flags:
The
--trigger-bucket
flag specifies the Cloud Storage bucket that the trigger will
monitor.
Object finalized events within this bucket will trigger calls to your
function.
This event type is supported for legacy functions already consuming these
events. However, we don't recommend using this event type as it might be
removed at a future date.
In the Bucket field, click Browse to select a
Cloud Storage bucket for the trigger to monitor. Changes to
objects within this bucket will trigger calls to your function.
Select or deselect the Retry on failure checkbox to control
whether failed function calls are automatically retried. See
Retrying event-driven functions
for more information.
A Cloud Storage bucket can have up to 10 notification configurations
set to trigger for a specific event. Exceeding the bucket's notifications limits
will cause further function deployments to fail with an error like the following:
You can work around this limitation by
managing your own Pub/Sub topic
and registering it for Cloud Storage notifications of the type you want your
function to respond to. For example, you could configure a single notification
for your chosen event (such as object creation) to a Pub/Sub topic.
Then, have as many function subscribers as needed to the topic process the event
and fan it out to multiple destinations. For example:
Create a single notification configuration on your Cloud Storage bucket
that triggers on a specific event (such as OBJECT_FINALIZE for object
creation) and sends the event to your single Pub/Sub topic.
Create a function (or functions) triggered by your
Pub/Sub topic.
See Cloud Storage Quotas and limits to learn more
about Cloud Storage limitations.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eCloud Storage triggers in Cloud Run functions (1st gen) allow functions to be activated by changes within a designated Cloud Storage bucket, specifying an event type and the bucket to monitor.\u003c/p\u003e\n"],["\u003cp\u003eSupported Cloud Storage event types include \u003ccode\u003eobject.finalize\u003c/code\u003e (new or overwritten object), \u003ccode\u003eobject.delete\u003c/code\u003e (permanent deletion), \u003ccode\u003eobject.archive\u003c/code\u003e (object becomes noncurrent), and \u003ccode\u003eobject.metadataUpdate\u003c/code\u003e (metadata changes).\u003c/p\u003e\n"],["\u003cp\u003eCloud Storage triggers use an event-driven function framework, where data is passed in CloudEvents format or \u003ccode\u003eStorageObjectData\u003c/code\u003e format, depending on the function type.\u003c/p\u003e\n"],["\u003cp\u003eDeployment of a function with a Cloud Storage trigger can be done via gcloud CLI, using \u003ccode\u003e--trigger-bucket\u003c/code\u003e, \u003ccode\u003e--trigger-event\u003c/code\u003e, and \u003ccode\u003e--trigger-resource\u003c/code\u003e flags, or via the Google Cloud console, choosing the trigger type, event type and associated bucket.\u003c/p\u003e\n"],["\u003cp\u003eA Cloud Storage bucket can only support up to 10 notification configurations, so exceeding this limit when deploying multiple functions to monitor a single bucket will lead to deployment failures.\u003c/p\u003e\n"]]],[],null,["# Cloud Storage triggers (1st gen)\n================================\n\nIn Cloud Run functions, a Cloud Storage trigger enables a function to be called\nin response to changes in [Cloud Storage](/storage/docs). When you\nspecify a Cloud Storage trigger for a function, you choose an event\ntype and specify a Cloud Storage bucket. Your function will be called\nwhenever a change occurs on an object (file) within the specified bucket.\n| **Note:** For a Cloud Run function to be triggered by an event on a Cloud Storage bucket, the function and the bucket must be in the same Google Cloud project.\n\nThe following Cloud Storage event types are supported:\n\nFor a function to use a Cloud Storage trigger, it must be implemented as an\n[event-driven function](/functions/1stgendocs/writing/write-event-driven-functions):\n\n- If you use a\n [CloudEvent function](/functions/1stgendocs/writing/write-event-driven-functions#cloudevent-functions),\n the Cloud Storage event data is passed to your function in the\n [CloudEvents format](/eventarc/docs/cloudevents) and the CloudEvent data\n payload is of type\n [`StorageObjectData`](https://github.com/googleapis/google-cloudevents/blob/main/proto/google/events/cloud/storage/v1/data.proto).\n\n- If you use a\n [background function](/functions/1stgendocs/writing/write-event-driven-functions#background-functions),\n the Cloud Storage event data payload is passed directly to your\n function in the\n [`StorageObjectData`](https://github.com/googleapis/google-cloudevents/blob/main/proto/google/events/cloud/storage/v1/data.proto)\n format.\n\nThe\n[Google Events](https://github.com/googleapis/google-cloudevents)\nrepository contains additional resources for working with event data.\n\nDeployment\n----------\n\nYou can specify a Cloud Storage trigger when you deploy a function. See\n[Deploy a Cloud Run function](/functions/1stgendocs/deploy) for\ngeneral instructions on how to deploy a function, and see the following for\nadditional information specific to configuring Cloud Storage triggers\nduring deployment. \n\n### gcloud\n\nIf you are\n[deploying using the gcloud CLI](/functions/1stgendocs/deploy#basics),\nyou can use the Cloud Storage *Object finalized* event type with the\nfollowing flags: \n\n```sh\ngcloud functions deploy YOUR_FUNCTION_NAME \\\n--no-gen2 \\\n--trigger-bucket=YOUR_STORAGE_BUCKET \\\n[--retry] \\\n...\n```\n\n- The [`--trigger-bucket`](/sdk/gcloud/reference/functions/deploy#--trigger-bucket) flag specifies the Cloud Storage bucket that the trigger will monitor. *Object finalized* events within this bucket will trigger calls to your function.\n- The [`--retry`](/sdk/gcloud/reference/functions/deploy#--retry) flag controls whether failed function calls are automatically retried. See [Retrying event-driven functions](/functions/1stgendocs/bestpractices/retries) for more information.\n\nTo use event types other than *Object finalized*, use the following flags:\n\n\u003cbr /\u003e\n\n```sh\n gcloud functions deploy YOUR_FUNCTION_NAME \n\n --no-gen2 \n\n --trigger-event=EVENT_TYPE \n\n --trigger-resource=YOUR_STORAGE_BUCKET \n\n ...\n \n```\n\n\u003cbr /\u003e\n\n**Legacy Cloud Storage events**\n\nLegacy functions in Cloud Run functions (1st gen) use legacy\n[object change notifications](/storage/docs/object-change-notification)\nfor Cloud Storage triggers: \n\n```sh\ngcloud functions deploy YOUR_FUNCTION_NAME \\\n--no-gen2 \\\n--trigger-event=providers/cloud.storage/eventTypes/object.change \\\n--trigger-resource=YOUR_STORAGE_BUCKET \\\n...\n```\n\nThis event type is supported for legacy functions already consuming these\nevents. However, we don't recommend using this event type as it might be\nremoved at a future date.\n\n### Console\n\nIf you are\n[deploying using the Google Cloud console](/functions/1stgendocs/deploy#console),\nyou can configure a Cloud Storage trigger in the **Trigger** section:\n\n1. In the **Trigger type** field, select **Cloud Storage**.\n2. In the **Event type** field, select an event type.\n3. In the **Bucket** field, click **Browse** to select a Cloud Storage bucket for the trigger to monitor. Changes to objects within this bucket will trigger calls to your function.\n4. Select or deselect the **Retry on failure** checkbox to control whether failed function calls are automatically retried. See [Retrying event-driven functions](/functions/1stgendocs/bestpractices/retries) for more information.\n\nEvent delivery\n--------------\n\nCloud Storage triggers are implemented with\n[Pub/Sub notifications for Cloud Storage](/storage/docs/pubsub-notifications).\nEvents are subject to\n[Pub/Sub notification delivery guarantees](/storage/docs/pubsub-notifications#delivery_guarantees).\n\nA Cloud Storage bucket can have up to 10 notification configurations\nset to trigger for a specific event. Exceeding the bucket's notifications limits\nwill cause further function deployments to fail with an error like the following: \n\n```\nCloud Storage bucket ...: Pub/Sub notification limit reached\n```\n\nYou can work around this limitation by\n[managing your own Pub/Sub topic](/storage/docs/reporting-changes)\nand registering it for Cloud Storage notifications of the type you want your\nfunction to respond to. For example, you could configure a single notification\nfor your chosen event (such as object creation) to a Pub/Sub topic.\nThen, have as many function subscribers as needed to the topic process the event\nand fan it out to multiple destinations. For example:\n\n1. [Create your own Pub/Sub topic](/pubsub/docs/create-topic).\n2. Create a single [notification configuration](/storage/docs/reporting-changes) on your Cloud Storage bucket that triggers on a specific event (such as `OBJECT_FINALIZE` for object creation) and sends the event to your single Pub/Sub topic.\n3. Create a function (or functions) triggered by your [Pub/Sub topic](/functions/1stgendocs/calling/pubsub).\n\nSee Cloud Storage [Quotas and limits](/storage/quotas) to learn more\nabout Cloud Storage limitations.\n\nNext steps\n----------\n\n- Learn how to [write event-driven functions](/functions/1stgendocs/writing/write-event-driven-functions).\n- Learn how to [deploy a Cloud Run function](/functions/1stgendocs/deploy).\n- See the [Cloud Storage function tutorial](/functions/1stgendocs/tutorials/storage-1st-gen) for an example of writing, deploying, and calling a function with a Cloud Storage trigger."]]