> ## 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.

# Use Kafka Tools With StreamNative Cloud

Apache Kafka provides a suite of command-line interface (CLI) tools that can be accessed from the `bin/` directory after [downloading](https://kafka.apache.org/downloads) and extracting the Kafka distribution. These tools offer a range of capabilities, including starting and stopping Kafka, managing topics, and handling partitions. To learn how to use each tool, simply run it with no argument or use the `--help` argument for detailed instructions.

You can use these tools by creating a configuration file that contains basic connectivity details such as the bootstrap server and a [API key](/cloud/security/authentication/service-accounts/use-api-keys/api-keys-overview). You can use this file with any Kafka tool that accepts a configuration file. Some of the tools that provide a configuration option, and the option to specify the configuration file are listsed in the table that follows:

| Kafka Tool                  | Config property option |
| --------------------------- | ---------------------- |
| `kafka-configs.sh`          | `--command-config`     |
| `kafka-console-consumer.sh` | `--consumer.config`    |
| `kafka-console-producer.sh` | `--producer.config`    |
| `kafka-consumer-groups.sh`  | `--command-config`     |

## Create a configuration file

1. Create a file named `cloud.properties` and save it in a secure location. You will populate this file with credentials to access your StreamNative Cloud account so you **must** keep in a safe place. Add the following content to the file:

   ```properties theme={null}
   bootstrap.servers=<broker-endpoint>
   security.protocol=SASL_SSL
   sasl.mechanism=PLAIN
   sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="unused" password="token:<api-key>";
   ```

2. Next, you will populate the file with your StreamNative Cloud cluster information.

   1. Sign in to your StreamNative Cloud account.

   2. In the Cloud Console, navigate to the cluster you want to connect to.

   3. In the **Cluster Dashboard** page, select the **Details** tab.

   4. Copy the **Kafka Service URL (TCP)** value and paste it into the `bootstrap.servers` property in the `cloud.properties` file.

   5. Follow the instructions in [Create an API key](/cloud/security/authentication/service-accounts/use-api-keys/api-keys-overview#create-an-api-key) to create an API key and paste the **API Key** value into the `cloud.properties` file.

## Use the tool

After you have set up the configuration file that references your cluster, you can use it with some of the Kafka tools. You will also need the bootstrap server of the cluster when you run the tool.

The following example demonstrates how to write messages to a topic named `test` in your StreamNative Cloud cluster using the `kafka-console-producer.sh` tool. The command requires both the configuration file and bootstrap server to be specified as options. Before running this command:

1. Ensure the topic `test` exists in your cluster
2. Replace `<bootstrap-server>` with your cluster's actual bootstrap server address
3. Update the path to point to your `cloud.properties` file location

```bash theme={null}
./bin/kafka-console-producer.sh --producer.config /path/to/secure/location/cloud.properties --bootstrap-server <bootstrap-server> --topic test
```

Now enter some messages at the prompt (>):

```bash theme={null}
>hello world
>another message
>3rd message
```

You can also use the `kafka-console-consumer.sh` tool to read messages from the topic.

```bash theme={null}
./bin/kafka-console-consumer.sh --consumer.config /path/to/secure/location/cloud.properties --bootstrap-server <bootstrap-server> --from-beginning --group test-group --topic test
```

You should see the following output:

```bash theme={null}
hello world
another message
3rd message
```
