gcloud pubsub lite-subscriptions create Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud pubsub lite-subscriptions create - create a Pub/Sub Lite subscription
- SYNOPSIS
gcloud pubsub lite-subscriptions createSUBSCRIPTION--topic=TOPIC[--delivery-requirement=DELIVERY_REQUIREMENT; default="deliver-immediately"][--location=LOCATION][--event-time=EVENT_TIME|--publish-time=PUBLISH_TIME|--starting-offset=STARTING_OFFSET; default="end"][--export-pubsub-topic=EXPORT_PUBSUB_TOPIC:--export-dead-letter-topic=EXPORT_DEAD_LETTER_TOPIC--export-desired-state=EXPORT_DESIRED_STATE; default="active"][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
- Create a Pub/Sub Lite subscription.
- EXAMPLES
- To create a Pub/Sub Lite subscription, run:
gcloudpubsublite-subscriptionscreatemysubscription--location=us-central1-a--topic=mytopicTo create a Pub/Sub Lite subscription at the offset of the oldest retainedmessage, run:
gcloudpubsublite-subscriptionscreatemysubscription--location=us-central1-a--topic=mytopic--starting-offset=beginningTo create a Pub/Sub Lite subscription that exports messages from a Pub/Sub Litetopic to a Pub/Sub topic, run:
gcloudpubsublite-subscriptionscreatemysubscription--location=us-central1-a--topic=mytopic--export-pubsub-topic=pubsubtopic - POSITIONAL ARGUMENTS
SUBSCRIPTION- Subscription ID.
- REQUIRED FLAGS
--topic=TOPIC- Topic ID associated with the subscription.
- OPTIONAL FLAGS
--delivery-requirement=DELIVERY_REQUIREMENT; default="deliver-immediately"- When this subscription should send messages to subscribers relative to messagespersistence in storage. Seehttps://cloud.google.com/pubsub/lite/docs/subscriptions#creating_lite_subscriptionsfor more info.
DELIVERY_REQUIREMENTmust be one of:deliver-after-stored,deliver-immediately. - Location resource - Identifies the Cloud zone this command will be executed on.This represents a Cloud resource. (NOTE) Some attributes are not given argumentsin this group but can be set in other ways.
To set the
projectattribute:- provide the argument
--locationon the command line with a fullyspecified name; - provide the argument
--zoneon the command line with a fullyspecified name; - provide the argument
--projecton the command line; - set the property
core/project.
- provide the argument
--location=LOCATION- ID of the location or fully qualified identifier for the location.
To set the
locationattribute:- provide the argument
--locationon the command line; - provide the argument
--zoneon the command line.
- provide the argument
- At most one of these can be specified:
--event-time=EVENT_TIME- The event time to which you seek a subscription. The subscription seeks to thefirst message with event time greater than or equal to the specified event time.Messages missing an event time use publish time as a fallback. As event timesare user supplied, subsequent messages may have event times less than thespecified event time and must be filtered by the client, if necessary. Run $gcloud topic datetimes forinformation on time formats.
--publish-time=PUBLISH_TIME- The publish time to which you seek a subscription. Messages with publish timegreater than or equal to the specified time are delivered after the seekoperation. Run $gcloud topicdatetimes for information on time formats.
--starting-offset=STARTING_OFFSET; default="end"- The offset at which a newly created or seeked subscription starts receivingmessages. A subscription can be initialized at the offset of the oldest retainedmessage (
beginning), or at the current HEAD offset(end).STARTING_OFFSETmust be one of:beginning,end.
--export-pubsub-topic=EXPORT_PUBSUB_TOPIC- The name of the destination Pub/Sub topic to which messages are exported. Mustbe the topic's fully specified path if it is not in the same project as thesubscription to be created.
--export-dead-letter-topic=EXPORT_DEAD_LETTER_TOPIC- The name of the Pub/Sub Lite topic to write messages that cannot be exported.Must be in the same project and location as the subscription to be created. Notethat this is a Lite topic.
--export-desired-state=EXPORT_DESIRED_STATE; default="active"- The desired state of the export. Process messages by setting the value to ACTIVEor pause message processing by setting the value to PAUSED.
EXPORT_DESIRED_STATEmust be one of:active,paused.
- 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 helpfor details. - API REFERENCE
- This command uses the
pubsublite/v1API. The full documentation forthis API can be found at:https://cloud.google.com/pubsub/lite/docs - NOTES
- These variants are also available:
gcloudalphapubsublite-subscriptionscreategcloudbetapubsublite-subscriptionscreate
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 2026-01-21 UTC.