gcloud storage buckets notifications create

NAME
gcloud storage buckets notifications create - create a notification configuration on a bucket
SYNOPSIS
gcloud storage buckets notifications createURL[--custom-attributes=[KEY=VALUE,…],-m [KEY=VALUE,…]][--event-types=[NOTIFICATION_EVENT_TYPE,…],-e [NOTIFICATION_EVENT_TYPE,…]][--object-prefix=OBJECT_PREFIX,-pOBJECT_PREFIX][--payload-format=PAYLOAD_FORMAT,-fPAYLOAD_FORMAT; default="json"][--skip-topic-setup,-s][--topic=TOPIC,-tTOPIC][GCLOUD_WIDE_FLAG]
DESCRIPTION
gcloud storage buckets notifications create creates a notificationconfiguration on a bucket, establishing a flow of event notifications from CloudStorage to a Cloud Pub/Sub topic. As part of creating this flow, it alsoverifies that the destination Cloud Pub/Sub topic exists, creating it ifnecessary, and verifies that the Cloud Storage bucket has permission to publishevents to that topic, granting the permission if necessary.

If a destination Cloud Pub/Sub topic is not specified with the-tflag, Cloud Storage chooses a topic name in the default project whose ID is thesame as the bucket name. For example, if the default project ID specified isdefault-project and the bucket being configured isgs://example-bucket, the create command uses the Cloud Pub/Subtopicprojects/default-project/topics/example-bucket.

In order to enable notifications, your project'sCloudStorage service agent must have the IAM permission "pubsub.topics.publish".This command checks to see if the destination Cloud Pub/Sub topic grants theservice agent this permission. If not, the create command attempts to grant it.

A bucket can have up to 100 total notification configurations and up to 10notification configurations set to trigger for a specific event.

EXAMPLES
Send notifications of all changes to the bucketexample-bucket tothe Cloud Pub/Sub topicprojects/default-project/topics/example-bucket:
gcloudstoragebucketsnotificationscreategs://example-bucket

The same as the above but sends no notification payload:

gcloudstoragebucketsnotificationscreate--payload-format=nonegs://example-bucket

Include custom metadata in notification payloads:

gcloudstoragebucketsnotificationscreate--custom-attributes=key1:value1,key2:value2gs://example-bucket

Create a notification configuration that only sends an event when a new objecthas been created or an object is deleted:

gcloudstoragebucketsnotificationscreate--event-types=OBJECT_FINALIZE,OBJECT_DELETEgs://example-bucket

Create a topic and notification configuration that sends events only when theyaffect objects with the prefixphotos/:

gcloudstoragebucketsnotificationscreate--object-prefix=photos/gs://example-bucket

Specifies the destination topic IDfiles-to-process in the defaultproject:

gcloudstoragebucketsnotificationscreate--topic=files-to-processgs://example-bucket

The same as above but specifies a Cloud Pub/Sub topic belonging to the specificcloud projectexample-project:

gcloudstoragebucketsnotificationscreate--topic=projects/example-project/topics/files-to-processgs://example-bucket

Skip creating a topic when creating the notification configuraiton:

gcloudstoragebucketsnotificationscreate--skip-topic-setupgs://example-bucket
POSITIONAL ARGUMENTS
URL
URL of the bucket to create the notification configuration on.
FLAGS
--custom-attributes=[KEY=VALUE,…],-m [KEY=VALUE,…]
Specifies key:value attributes that are appended to the set of attributes sentto Cloud Pub/Sub for all events associated with this notification configuration.
--event-types=[NOTIFICATION_EVENT_TYPE,…],-e [NOTIFICATION_EVENT_TYPE,…]
Specify event type filters for this notification configuration. Cloud Storagewill send notifications of only these types. By default, Cloud Storage sendsnotifications for all event types. * OBJECT_FINALIZE: An object has beencreated. * OBJECT_METADATA_UPDATE: The metadata of an object has changed. *OBJECT_DELETE: An object has been permanently deleted. * OBJECT_ARCHIVE: A liveversion of an object has become a noncurrent version.NOTIFICATION_EVENT_TYPE must be one of:OBJECT_ARCHIVE,OBJECT_DELETE,OBJECT_FINALIZE,OBJECT_METADATA_UPDATE.
--object-prefix=OBJECT_PREFIX,-pOBJECT_PREFIX
Specifies a prefix path for this notification configuration. Cloud Storage willsend notifications for only objects in the bucket whose names begin with theprefix.
--payload-format=PAYLOAD_FORMAT,-fPAYLOAD_FORMAT; default="json"
Specifies the payload format of notification messages. Notification details areavailable in the message attributes. 'none' sends no payload.PAYLOAD_FORMAT must be one of:json,none.
--skip-topic-setup,-s
Skips creation and permission assignment of the Cloud Pub/Sub topic. This isuseful if the caller does not have permission to access the topic in question,or if the topic already exists and has the appropriate publish permissionassigned.
--topic=TOPIC,-tTOPIC
Specifies the Cloud Pub/Sub topic to send notifications to. If not specified,this command chooses a topic whose project is your default project and whose IDis the same as the Cloud Storage bucket name.
GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
This variant is also available:
gcloudalphastoragebucketsnotificationscreate

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-05-07 UTC.