Managing Confluent Cloud using Terraform.
Create a Confluent Cloud Cloud API Key
Create a service account called tf_runnerin Confluent Cloud
Assign the OrganizationAdmin role to the tf_runner service account
Create a Cloud API Key for the tf_runner service account
Terraform will use the following environment variables to authenticate with Confluent Cloud.
export CONFLUENT_CLOUD_API_KEY="<CONFLUENT_CLOUD_API_KEY>"
export CONFLUENT_CLOUD_API_SECRET="<CONFLUENT_CLOUD_API_SECRET>"- Provide a Confluent Cloud Environment ID.
environment: Confluent Cloud Environment ID
- Provide Cluster details
cluster: Cluster map.(Defaults)display_name= "sandbox"availability= "SINGLE_ZONE"cloud= "GCP"region= "europe-west1"type= "BASIC"
- Provide a Service Account Name to create a ClusterAdmin role binding.
service_account: Service Account Name
terraform initBuild the plan.
terraform plan --var-file=sandbox.tfvarsApply - Using auto-approve skips interactive approval of plan before applying.
terraform apply -auto-approve --var-file=sandbox.tfvars- Outputs
- Cluster Bootstrap Server endpoint:
terraform show -json terraform.tfstate | jq '.values.outputs.cluster.value.bootstrap_endpoint'- Confluent Cloud Cluster API_KEY:
terraform show -json terraform.tfstate | jq '.values.outputs.cluster_api_key.value.id'- Confluent Cloud Cluster API_SECRET:
terraform show -json terraform.tfstate | jq '.values.outputs.cluster_api_key.value.secret'terraform destroy --var-file=sandbox.tfvarsor
terraform apply -auto-approve -destroy --var-file=sandbox.tfvars| Name | Source | Version |
|---|---|---|
| cluster | github.com/mcolomerc/terraform-confluent-kafka-cluster | v1.0.0 |
| cluster_admin_service_account | github.com/mcolomerc/terraform-confluent-iam | v1.0.2 |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster | Cluster | map(any) |
{ |
no |
| confluent_cloud_api_key | Confluent Cloud API Key | string |
n/a | yes |
| confluent_cloud_api_secret | Confluent Cloud API Secret | string |
n/a | yes |
| environment | Environment | string |
n/a | yes |
| service_account | Service Account Name | string |
n/a | yes |
| Name | Description |
|---|---|
| cluster | n/a |
| cluster_api_key | n/a |
| cluster_id | n/a |