Question
How can I use API to manage clusters on ClickHouse Cloud?Answer
We will use Terraform to configure our infra and ClickHouse Provider Steps: 1). Create an API Key on Cloud. Follow the docs here - https://clickhouse.com/docs/cloud/manage/openapi Save the creds locally. 2). Install Terraform using - https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli You can use Homebrew package manager if you’re on Mac. 3). Create a directory anywhere you like:main.tf and secret.tfvars
Copy the following:
main.tf file would be:
secret.tfvars is where you’ll put all the API Key related info that you downloaded earlier. The idea behind this file is that all your secret credentials will be hidden from the main config file.
It would be something like (replace these parameters):
terraform init from this directory
Expected output:
terraform apply -var-file=secret.tfvars command.
Something like:
yes and hit enter
Side note: Notice it says password = (sensitive value) above.
This is because we set sensitive = true for the password in the main.tf file.
7). It will take a couple of mins to create the service but eventually it should come up like:
terraform destroy -var-file=secret.tfvars
Something like: