# PubSubTopic

| **Property** | **Value** |
|---|---|
| Google Cloud Service Name | Cloud Pub/Sub |
| Google Cloud Service Documentation | [/pubsub/docs/](https://docs.cloud.google.com/pubsub/docs) |
| Google Cloud REST Resource Name | v1.projects.topics |
| Google Cloud REST Resource Documentation | <https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics> |
| Config Connector Resource Short Names | gcppubsubtopic gcppubsubtopics pubsubtopic |
| Config Connector Service Name | pubsub.googleapis.com |
| Config Connector Resource Fully Qualified Name | pubsubtopics.pubsub.cnrm.cloud.google.com |
| Can Be Referenced by IAMPolicy/IAMPolicyMember | Yes |
| Supports IAM Conditions | No |
| Supports IAM Audit Configs | No |
| IAM External Reference Format | projects/{{project}}/topics/{{name}} |
| Config Connector Default Average Reconcile Interval In Seconds | 600 |

## Custom Resource Definition Properties

### Annotations

| Fields ||
|---|---|
| `cnrm.cloud.google.com/project-id` |

### Spec

#### Schema

    kmsKeyRef:
      external: string
      name: string
      namespace: string
    messageRetentionDuration: string
    messageStoragePolicy:
      allowedPersistenceRegions:
      - string
      enforceInTransit: boolean
    resourceID: string
    schemaSettings:
      encoding: string
      schemaRef:
        external: string
        name: string
        namespace: string

| Fields ||
|---|---|
| `kmsKeyRef` *Optional* | `object` The KMSCryptoKey to be used to protect access to messages published on this topic. Your project's Pub/Sub service account ('service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com') must have 'roles/cloudkms.cryptoKeyEncrypterDecrypter' to use this feature. |
| `kmsKeyRef.external` *Optional* | `string` A reference to an externally managed KMSCryptoKey resource. Should be in the format "projects/{{projectID}}/locations/{{location}}/keyRings/{{keyring}}/cryptoKeys/{{cryptokey}}". |
| `kmsKeyRef.name` *Optional* | `string` The name of a KMSCryptoKey resource. |
| `kmsKeyRef.namespace` *Optional* | `string` The namespace of a KMSCryptoKey resource. |
| `messageRetentionDuration` *Optional* | `string` 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 messageRetentionDuration are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to messageRetentionDuration in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. Cannot be more than 31 days or less than 10 minutes. |
| `messageStoragePolicy` *Optional* | `object` Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect. |
| `messageStoragePolicy.allowedPersistenceRegions` *Required\** | `list (string)` A list of IDs of Google Cloud regions where messages that are published to the topic may be persisted in storage. Messages published by publishers running in non-allowed Google Cloud regions (or running outside of Google Cloud altogether) will be routed for storage in one of the allowed regions. An empty list means that no regions are allowed, and is not a valid configuration. |
| `messageStoragePolicy.allowedPersistenceRegions[]` *Required\** | `string` <br /> |
| `messageStoragePolicy.enforceInTransit` *Optional* | `boolean` Optional. If true, \`allowed_persistence_regions\` is also used to enforce in-transit guarantees for messages. That is, Pub/Sub will fail Publish operations on this topic and subscribe operations on any subscription attached to this topic in any region that is not in \`allowed_persistence_regions\`. |
| `resourceID` *Optional* | `string` Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of \`metadata.name\` is used as the default. |
| `schemaSettings` *Optional* | `object` Settings for validating messages published against a schema. |
| `schemaSettings.encoding` *Optional* | `string` The encoding of messages validated against schema. Default value: "ENCODING_UNSPECIFIED" Possible values: \["ENCODING_UNSPECIFIED", "JSON", "BINARY"\]. |
| `schemaSettings.schemaRef` *Required\** | `object` PubSubSchemaRef is a reference to a PubSubSchema. |
| `schemaSettings.schemaRef.external` *Optional* | `string` A reference to an externally managed PubSubSchema resource. Should be in the format "projects/{{projectID}}/schemas/{{schemaID}}". |
| `schemaSettings.schemaRef.name` *Optional* | `string` The name of a PubSubSchema resource. |
| `schemaSettings.schemaRef.namespace` *Optional* | `string` The namespace of a PubSubSchema resource. |

\* Field is required when parent field is specified

### Status

#### Schema

    conditions:
    - lastTransitionTime: string
      message: string
      reason: string
      status: string
      type: string
    observedGeneration: integer

| Fields ||
|---|---|
| `conditions` | `list (object)` Conditions represent the latest available observations of the object's current state. |
| `conditions[]` | `object` <br /> |
| `conditions[].lastTransitionTime` | `string` Last time the condition transitioned from one status to another. |
| `conditions[].message` | `string` Human-readable message indicating details about last transition. |
| `conditions[].reason` | `string` Unique, one-word, CamelCase reason for the condition's last transition. |
| `conditions[].status` | `string` Status is the status of the condition. Can be True, False, Unknown. |
| `conditions[].type` | `string` Type is the type of the condition. |
| `observedGeneration` | `integer` ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |

## Sample YAML(s)

### Typical Use Case

    # Copyright 2020 Google LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
    kind: PubSubTopic
    metadata:
      labels:
        label-one: "value-one"
      name: pubsubtopic-sample
    spec:
      schemaSettings:
        schemaRef:
          name: pubsubtopic-dep
        encoding: JSON
    ---
    apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
    kind: PubSubSchema
    metadata:
      name: pubsubtopic-dep
    spec:
      type: PROTOCOL_BUFFER
      definition: "syntax = \"proto3\";\nmessage Results {\nstring message_request = 1;\nstring message_response = 2;\nstring timestamp_request = 3;\nstring timestamp_response = 4;\n}"
      # Replace ${PROJECT_ID?} below with your project ID
      projectRef:
        external: ${PROJECT_ID?}

> [!NOTE]
> **Note:** If you have any trouble with instantiating the resource, refer to [Troubleshoot Config Connector](https://docs.cloud.google.com/config-connector/docs/troubleshooting).