Configure a Pub/Sub topic and subscription

In Application Design Center, you can configure a Pub/Sub topic and subscription to provide asynchronous, scalable messaging that decouples services producing messages from services processing them. You can customize the component connections and configuration parameters for your topic and subscription based on the terraform-google-pubsub Terraform module on GitHub.

Component connections

The following table includes the components that you can connect to a Pub/Sub topic or subscription, and the resulting updates to your application and its generated Terraform code.

Connected component Application updates Background information

Compute Engine instance template

  • The Compute Engine instances can publish to and receive messages from the Pub/Sub topic.
  • The Pub/Sub topic ID is added to the Compute Engine instance template metadata.
Instance templates

Service account

  • The service account can manage Pub/Sub topics, and pull messages from subscriptions.
  • The roles/pubsub.editor role is granted to the service account.
  • The service account name and email information is added to the Pub/Sub pull subscription.
Access control with Identity and Access Management (IAM)

BigQuery

  • The Pub/Sub subscription can write messages to a table in the BigQuery dataset.
  • The BigQuery dataset and table information is added to the Pub/Sub subscription fields.
BigQuery subscriptions

Cloud Run

  • The Cloud Run service can receive messages or publish to the Pub/Sub topic.
  • The Pub/Sub topic ID is added to the Cloud Run environment variables.
  • The roles/pubsub.publisher and roles/pubsub.subscriber roles are granted to the Cloud Run service account.
  • The Cloud Run service is added to the Pub/Sub push and pull subscription fields.
Use Pub/Sub with Cloud Run tutorial

Cloud Storage

  • The Pub/Sub subscription can write messages to the Cloud Storage bucket.
  • The Cloud Storage bucket information is added to the Pub/Sub subscription fields.
Cloud Storage subscriptions

Required configuration parameters

If your template includes a Pub/Sub component, you must configure the following parameters before you deploy.

Parameter name Description and constraints Background information

Project ID

The project where you want to deploy the Pub/Sub resource.

Configure components

Topic

name Guidelines to name a topic, subscription, schema, or snapshot

Optional configuration parameters

The following parameters are optional. To display advanced parameters, in the Configuration area, select Show advanced fields.

Feature Parameter name Description and constraint information Background information
Create Topic By default, a topic is created. Clear the checkbox if you don't want to create a topic. Create a topic
Create Subscriptions By default, a subscription is created. Clear the checkbox if you don't want to create a subscription. Subscription overview
Topic Labels Key labels Reporting usage with labels
Topic Labels Value labels Reporting usage with labels
Push Subscriptions Name name Guidelines to name a topic, subscription, schema, or snapshot
Push Subscriptions Ack Deadline Seconds ackDeadlineSeconds Acknowledgment deadline
Push Subscriptions Push Endpoint pushEndpoint Endpoints
Push Subscriptions X-goog-version The Pub/Sub API format of the pushed message. For example, v1beta1. attributes
Push Subscriptions OIDC Service Account email serviceAccountEmail Authentication
Push Subscriptions Audience audience Authentication
Push Subscriptions Expiration Policy expirationPolicy Expiration period
Push Subscriptions Dead Letter Topic deadLetterTopic Dead letter topic
Push Subscriptions Retain Acked Messages retainAckedMessages Retain acknowledged messages
Push Subscriptions Message Retention Duration messageRetentionDuration Message retention duration
Push Subscriptions Max Delivery Attempts maxDeliveryAttempts Dead letter topic
Push Subscriptions Maximum Backoff maximumBackoff Retry policy
Push Subscriptions Minimum Backoff minimumBackoff Retry policy
Push Subscriptions Filter filter Subscription filter
Push Subscriptions Enable Message Ordering enableMessageOrdering Message ordering
Pull Subscriptions Name name Guidelines to name a topic, subscription, schema, or snapshot
Pull Subscriptions Ack Deadline Seconds ackDeadlineSeconds Acknowledgment deadline
Pull Subscriptions Dead Letter Topic deadLetterTopic Dead letter topic
Pull Subscriptions Max Delivery Attempts maxDeliveryAttempts Dead letter topic
Pull Subscriptions Retain Acked Messages retainAckedMessages Retain acknowledged messages
Pull Subscriptions Message Retention Duration messageRetentionDuration Message retention duration
Pull Subscriptions Maximum Backoff maximumBackoff Retry policy
Pull Subscriptions Minimum Backoff minimumBackoff Retry policy
Pull Subscriptions Filter filter Subscription filter
Pull Subscriptions Enable Message Ordering enableMessageOrdering Message ordering
Pull Subscriptions Service Account The service account that is granted the roles/pubsub.subscriber role on the subscription. Access control with IAM
Pull Subscriptions Enable Exactly Once Delivery enableExactlyOnceDelivery Exactly-once delivery
BigQuery Subscriptions Name name Guidelines to name a topic, subscription, schema, or snapshot
BigQuery Subscriptions Table table Create BigQuery subscriptions
BigQuery Subscriptions Use Topic Schema useTopicSchema Use topic schema
BigQuery Subscriptions Use Table Schema useTableSchema Use table schema
BigQuery Subscriptions Write Metadata writeMetadata Write metadata
BigQuery Subscriptions Drop Unknown Fields dropUnknownFields Drop unknown fields
BigQuery Subscriptions Ack Deadline Seconds ackDeadlineSeconds Acknowledgment deadline
BigQuery Subscriptions Retain Acked Messages retainAckedMessages Retain acknowledged messages
BigQuery Subscriptions Message Retention Duration messageRetentionDuration Message retention duration
BigQuery Subscriptions Enable Message Ordering enableMessageOrdering Message ordering
BigQuery Subscriptions Expiration Policy expirationPolicy Expiration period
BigQuery Subscriptions Filter filter Subscription filter
BigQuery Subscriptions Dead Letter Topic deadLetterTopic Dead letter topic
BigQuery Subscriptions Maximum Backoff maximumBackoff Retry policy
BigQuery Subscriptions Minimum Backoff minimumBackoff Retry policy
Cloud Storage Subscriptions Name name Guidelines to name a topic, subscription, schema, or snapshot
Cloud Storage Subscriptions Bucket bucket Bucket name
Cloud Storage Subscriptions Filename Prefix filenamePrefix Filename prefix, suffix, and datetime
Cloud Storage Subscriptions Filename Suffix filenameSuffix Filename prefix, suffix, and datetime
Cloud Storage Subscriptions Filename Datetime Format filenameDatetimeFormat Filename prefix, suffix, and datetime
Cloud Storage Subscriptions Max Duration maxDuration File batching
Cloud Storage Subscriptions Max Bytes maxBytes File batching
Cloud Storage Subscriptions Max Messages maxMessages File batching
Cloud Storage Subscriptions Output Format textConfig or avroConfig File format
Cloud Storage Subscriptions Write Metadata writeMetadata File format
Cloud Storage Subscriptions Use Topic Schema useTopicSchema File format
Cloud Storage Subscriptions Ack Deadline Seconds ackDeadlineSeconds Acknowledgment deadline
Cloud Storage Subscriptions Retain Acked Messages retainAckedMessages Retain acknowledged messages
Cloud Storage Subscriptions Message Retention Duration messageRetentionDuration Message retention duration
Cloud Storage Subscriptions Enable Message Ordering enableMessageOrdering Message ordering
Cloud Storage Subscriptions Expiration Policy expirationPolicy Expiration period
Cloud Storage Subscriptions Filter filter Subscription filter
Cloud Storage Subscriptions Dead Letter Topic deadLetterTopic Dead letter topic
Cloud Storage Subscriptions Maximum Backoff maximumBackoff Retry policy
Cloud Storage Subscriptions Minimum Backoff minimumBackoff Retry policy
Subscription Labels Key labels Reporting usage with labels
Subscription Labels Value labels Reporting usage with labels
Topic Message Retention Duration topicMessageRetentionDuration Message retention duration
Topic KMS Key Name kmsKeyName Use a customer-managed encryption key (CMEK)
Grant BigQuery Project Roles By default, the BigQuery Metadata Viewer (roles/bigquery.metadataViewer) and BigQuery Data Editor (roles/bigquery.dataEditor) roles are granted to the default Pub/Sub service account. If you don't want to grant these roles, clear the checkbox. Grant IAM roles to the service account
Grant Token Creator By default, the Service Account Token Creator role is granted to the default Pub/Sub service account. If you don't want to grant this role, clear the checkbox. Set up authentication for Pub/Sub
Schema Name name Important information about schemas
Schema Type type Types of schemas
Schema Definition definition Types of schemas
Schema Encoding encoding Guidelines to associate a schema with a topic