gcloud alpha pubsub topics create - creates one or more Cloud Pub/Sub topics
gcloud alpha pubsub topics create TOPIC [TOPIC ...] [--labels=[KEY=VALUE,...]] [--message-retention-duration=MESSAGE_RETENTION_DURATION] [--message-storage-policy-allowed-regions=[REGION,...]] [--message-encoding=ENCODING (--schema=SCHEMA : --schema-project=SCHEMA_PROJECT) : --first-revision-id=FIRST_REVISION_ID --last-revision-id=LAST_REVISION_ID] [--topic-encryption-key=TOPIC_ENCRYPTION_KEY : --topic-encryption-key-keyring=TOPIC_ENCRYPTION_KEY_KEYRING --topic-encryption-key-location=TOPIC_ENCRYPTION_KEY_LOCATION --topic-encryption-key-project=TOPIC_ENCRYPTION_KEY_PROJECT] [GCLOUD_WIDE_FLAG ...]
(ALPHA) Creates one or more Cloud Pub/Sub topics.
To create a Cloud Pub/Sub topic, run:
$ gcloud alpha pubsub topics create mytopic
- Topic resource - One or more topics to create. This represents a Cloud
resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways. To set the project attribute:
- —
provide the argument topic on the command line with a fully specified name;
- —
provide the argument --project on the command line;
- —
set the property core/project.
This must be specified.
- TOPIC [TOPIC ...]
IDs of the topics or fully qualified identifiers for the topics. To set the topic attribute:
provide the argument topic on the command line.
- --labels=[KEY=VALUE,...]
List of label KEY=VALUE pairs to add.
Keys must start with a lowercase character and contain only hyphens (-), underscores (_), lowercase characters, and numbers. Values must contain only hyphens (-), underscores (_), lowercase characters, and numbers.
- --message-retention-duration=MESSAGE_RETENTION_DURATION
Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last MESSAGE_RETENTION_DURATION are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to MESSAGE_RETENTION_DURATION in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. The minimum is 10 minutes and the maximum is 31 days. Valid values are strings of the form INTEGER[UNIT], where UNIT is one of "s", "m", "h", and "d" for seconds, minutes, hours, and days, respectively. If the unit is omitted, seconds is assumed.
- --message-storage-policy-allowed-regions=[REGION,...]
A list of one or more Cloud regions where messages are allowed to be stored at rest.
- Schema settings. The schema that messages published to this topic must conform
to and the expected message encoding.
- --message-encoding=ENCODING
The encoding of messages validated against the schema. ENCODING must be one of: json, binary.
This flag argument must be specified if any of the other arguments in this group are specified.
- --first-revision-id=FIRST_REVISION_ID
The id of the oldest revision allowed for the specified schema.
- --last-revision-id=LAST_REVISION_ID
The id of the most recent revision allowed for the specified schema
- Schema resource - Name of the schema that messages published to this topic must
conform to. The arguments in this group can be used to specify the attributes of this resource.
This must be specified.
- --schema=SCHEMA
ID of the schema or fully qualified identifier for the schema. To set the schema attribute:
- —
provide the argument --schema on the command line.
This flag argument must be specified if any of the other arguments in this group are specified.
- --schema-project=SCHEMA_PROJECT
Project ID of the Google Cloud project for the schema. To set the project attribute:
- —
provide the argument --schema on the command line with a fully specified name;
- —
provide the argument --schema-project on the command line;
- —
provide the argument --project on the command line;
- —
set the property core/project.
- Key resource - The Cloud KMS (Key Management Service) cryptokey that will be
used to protect the topic. The specified Cloud KMS key should have purpose set to "ENCRYPT_DECRYPT". The service account, "service-${CONSUMER_PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com" requires the IAM cryptoKeyEncrypterDecrypter role for the given Cloud KMS key. CONSUMER_PROJECT_NUMBER is the project number of the project that is the parent of the topic being created. The arguments in this group can be used to specify the attributes of this resource.
- --topic-encryption-key=TOPIC_ENCRYPTION_KEY
ID of the key or fully qualified identifier for the key. To set the kms-key attribute:
provide the argument --topic-encryption-key on the command line.
This flag argument must be specified if any of the other arguments in this group are specified.
- --topic-encryption-key-keyring=TOPIC_ENCRYPTION_KEY_KEYRING
The KMS keyring of the key. To set the kms-keyring attribute:
provide the argument --topic-encryption-key on the command line with a fully specified name;
provide the argument --topic-encryption-key-keyring on the command line.
- --topic-encryption-key-location=TOPIC_ENCRYPTION_KEY_LOCATION
The Cloud location for the key. To set the kms-location attribute:
provide the argument --topic-encryption-key on the command line with a fully specified name;
provide the argument --topic-encryption-key-location on the command line.
- --topic-encryption-key-project=TOPIC_ENCRYPTION_KEY_PROJECT
The Cloud project for the key. To set the kms-project attribute:
provide the argument --topic-encryption-key on the command line with a fully specified name;
provide the argument --topic-encryption-key-project on the command line;
set the property core/project.
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.
This command is currently in alpha and might change without notice. If this command fails with API permission errors despite specifying the correct project, you might be trying to access an API with an invitation-only early access allowlist. These variants are also available:
$ gcloud pubsub topics create
$ gcloud beta pubsub topics create