> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamnative.io/llms.txt
> Use this file to discover all available pages before exploring further.

> The official Google Cloud Pub/Sub Lite Sink connector.

# Kafka connect google pubsub lite sink

The Google Cloud Pub/Sub Group Kafka Connector library provides Google Cloud
Platform (GCP) first-party connectors for Pub/Sub products with
[Kafka Connect](http://kafka.apache.org/documentation.html#connect).
You can use the library to transmit data from
[Apache Kafka](http://kafka.apache.org)
to [Cloud Pub/Sub](https://cloud.google.com/pubsub/docs/) or
[Pub/Sub Lite](https://cloud.google.com/pubsub/lite/docs) and vice versa.

### Prerequisites

You must have a GCP project in order to use Cloud Pub/Sub or Pub/Sub Lite.

Follow these [setup steps](https://cloud.google.com/pubsub/docs/publish-receive-messages-client-library#before-you-begin)
for Pub/Sub before doing the [quickstart](#quickstart).

Follow these [setup steps](https://cloud.google.com/pubsub/lite/docs/publish-receive-messages-console#before-you-begin)
for Pub/Sub Lite before doing the [quickstart](#quickstart).

For general information on how to authenticate with GCP when using the Google
Cloud Pub/Sub Group Kafka Connector library, please visit [Provide credentials
for Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).

### Quick Start

1. Setup the kcctl client: [doc](https://docs.streamnative.io/docs/kafka-connect-setup)
2. Create a Pub/Sub topic in your GCP project.
3. Create a JSON file like the following:

```json theme={null}
{
    "name": "pubsub-sink",
    "config": {
        "connector.class": "com.google.pubsublite.kafka.sink.PubSubLiteSinkConnector",
        "pubsublite.project": "${GCP_PROJECT_ID}",
        "pubsublite.topic": "${PUBSUB_TOPIC_NAME}",
        "pubsublite.location": "${PUBSUB_LOCATION}",
        "gcp.credentials.json": "${GCP_CREDENTIALS_JSON}",
        "topics": "${KAFKA_TOPIC_NAME}"
    }
}
```

4. Run the following command to create the connector:

```shell theme={null}
kcctl apply -f <filename>.json
```

### Configuration

The Google Pub/Sub Lite sink connector is configured using the following properties:

| Config                    | Value Range | Default               | Description                                                                                                                                                                                                                                                                 |
| ------------------------- | ----------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pubsublite.topic          | String      | REQUIRED (No default) | The Pub/Sub Lite topic ID, e.g. "foo" for topic "/projects/bar/locations/europe-south7-q/topics/foo".                                                                                                                                                                       |
| pubsublite.project        | String      | REQUIRED (No default) | The project containing the Pub/Sub Lite topic, e.g. "bar" from above.                                                                                                                                                                                                       |
| pubsublite.location       | String      | REQUIRED (No default) | The location of the Pub/Sub Lite topic, e.g. "europe-south7-q" from above.                                                                                                                                                                                                  |
| gcp.credentials.file.path | String      | Optional              | The filepath, which stores GCP credentials. If not defined, the environment variable GOOGLE\_APPLICATION\_CREDENTIALS is used. If specified, use the explicitly handed credentials. Consider using the externalized secrets feature in Kafka Connect for passing the value. |
| gcp.credentials.json      | String      | Optional              | GCP credentials JSON blob. If specified, use the explicitly handed credentials. Consider using the externalized secrets feature in Kafka Connect for passing the value.                                                                                                     |

The full properties are also available from the [Official Google Pub/Sub Lite Kafka Sink Connector documentation](https://github.com/googleapis/java-pubsub-group-kafka-connector?tab=readme-ov-file#sink-connector-1).
