HashiCorp Terraform is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle.
With the Qdrant Terraform Provider, you can manage the Qdrant cloud lifecycle leveraging all the goodness of Terraform.
Pre-requisites
To use the Qdrant Terraform Provider, you’ll need:
- A Terraform installation.
- An API key to access the Qdrant cloud API.
Example Usage
The following example creates a new Qdrant cluster in Google Cloud Platform (GCP) and returns the URL of the cluster.
terraform {
required_version = ">= 1.7.0"
required_providers {
qdrant-cloud = {
source = "qdrant/qdrant-cloud"
version = ">=1.1.0"
}
}
}
provider "qdrant-cloud" {
api_key = "<QDRANT_CLOUD_API_KEY>"
account_id = "QDRANT_ACCOUNT_ID>" // Account ID from cloud.qdrant.io/accounts/<QDRANT_ACCOUNT_ID>/ (can be overriden on resource level)
}
data "qdrant-cloud_booking_packages" "all_packages" {
cloud_provider = "gcp" // Required. Please refer to the documentation (https://registry.terraformio/providers/qdrant/qdrant-cloud/latest/docs/guides/getting-started) for the available options.
cloud_region = "us-east4" // Required. Please refer to the documentation (https://registry.terraformio/providers/qdrant/qdrant-cloud/latest/docs/guides/getting-started) for the available options.
}
locals {
desired_package = [
for pkg in data.qdrant-cloud_booking_packages.all_packages.packages : pkg
if pkg.resource_configuration[0].cpu == "16000m" && pkg.resource_configuration[0].ram == "64Gi"
]
}
resource "qdrant-cloud_accounts_cluster" "example" {
name = "tf-example-cluster"
cloud_provider = data.qdrant-cloud_booking_packages.all_aws_eu_west_1_packages.cloud_provider
cloud_region = data.qdrant-cloud_booking_packages.all_aws_eu_west_1_packages.cloud_region
configuration {
number_of_nodes = 1
database_configuration {
service {
jwt_rbac = true
}
}
node_configuration {
package_id = local.desired_package[0].id
}
}
}
resource "qdrant-cloud_accounts_database_api_key_v2" "example" {
cluster_id = qdrant-cloud_accounts_cluster.example.id
name = "example-key"
}
output "url" {
value = qdrant-cloud_accounts_cluster.example.url
}
output "key" {
value = qdrant-cloud_accounts_database_api_key_v2.example.key
description = "Key is available only once, after creation."
}
Further Reading
The provider documentation contains more details on the available resources and data sources, including additional examples: