This project demonstrates how to use a Confluent Cloud Gateway to provide network isolation and a custom domain name for a Confluent Cloud Kafka cluster.
The entire infrastructure on Confluent Cloud is provisioned automatically using Terraform, and the gateway is run locally using Docker Compose.
Before you begin, ensure you have the following tools installed:
You will also need a Confluent Cloud account.
The Terraform scripts require your Confluent Cloud API key and secret. You can provide these credentials using one of the following methods.
Create a file named terraform.tfvars in the root of the project with the following content:
confluent_cloud_api_key = "YOUR_CONFLUENT_CLOUD_API_KEY"
confluent_cloud_api_secret = "YOUR_CONFLUENT_CLOUD_API_SECRET"Replace the placeholder values with your actual Confluent Cloud credentials. Terraform automatically loads variables from this file.
You can provide the Terraform input variables via environment variables by prefixing them with TF_VAR_.
In your terminal, export the following variables:
export TF_VAR_confluent_cloud_api_key="YOUR_CONFLUENT_CLOUD_API_KEY"
export TF_VAR_confluent_cloud_api_secret="YOUR_CONFLUENT_CLOUD_API_SECRET"Replace the placeholder values with your actual credentials. Terraform will automatically use these environment variables to populate the confluent_cloud_api_key and confluent_cloud_api_secret input variables.
The project includes simple scripts to set up and tear down the entire demo environment.
To provision the Confluent Cloud resources and start the local gateway, run the setup script:
bash setup.shThis script performs the following actions:
- Generates the necessary self-signed TLS certificates for the custom domain.
- Initializes Terraform (
terraform init). - Provisions the Confluent Cloud environment, Kafka cluster, service account, and API keys (
terraform apply). - Starts the Confluent Gateway service locally via
docker compose up.
To stop the gateway and destroy all cloud resources, run the teardown script:
bash teardown.shThis script will:
- Stop and remove the local Docker containers and their volumes (
docker compose down -v). - Destroy all infrastructure previously created by Terraform (
terraform destroy).