The Terraform Provider for Qrator allows you to manage Qrator resources through Terraform configurations instead of manually configuring them in the interface. The provider is published in the Terraform Registry as QratorLabs/qrator, supports Terraform 1.0+, and works with domains, services, CDN configurations, and client certificates.
Prepare the Terraform configuration
Add the provider to the required_providers block:
terraform {
required_providers {
qrator = {
source = "qratorlabs/qrator"
version = "~> 0.2"
}
}
}
Configure authentication
The provider requires an API key to access the Qrator API. Authentication can be set either in the provider block or via environment variables. The README provides both options: api_key and endpoint in the configuration, or QRATOR_API_KEY and QRATOR_ENDPOINT in the environment.
Example using a provider block:
provider "qrator" {
api_key = var.api_key
endpoint = "https://api.qrator.net"
}
Example using environment variables:
export QRATOR_API_KEY="your-api-key"export QRATOR_ENDPOINT="https://api.qrator.net"
Initialize Terraform
After adding the provider, perform standard initialization: terraform init.
Then, the provider follows the usual Terraform cycle: plan to check for changes and apply to apply the configuration.
What can be managed through the provider
The provider supports the following resource groups:
Domains
qrator_domainqrator_domain_servicesqrator_domain_sniqrator_domain_whitelistqrator_domain_blacklist
Services
qrator_serviceqrator_service_servicesqrator_service_sniqrator_service_whitelistqrator_service_blacklist
CDN and Certificates
qrator_cdnqrator_cdn_sniqrator_client_certificate
Operation Scenarios
Two main scenarios are supported.
Scenario 1: Create a new configuration
If the domain, service, or CDN configuration has not yet been created, describe them in .tf files and run:
terraform planterraform apply
The process is described in detail in the documentation.
Scenario 2: Connecting existing resources
If resources already exist in Qrator, they can be managed by Terraform without recreating them.
The basic workflow is:
- Describe the resource in
.tf; - Run
terraform import; - Verify the
terraform plan; - Match the
.tfconfiguration to the actual state; - Run
terraform apply.
The process is described in detail in the documentation.
Recommended Workflow
For practical use, the following workflow is recommended:
New resource
terraform initterraform planterraform apply
Existing resource
terraform initterraform importterraform planterraform apply
This workflow is required to first synchronize the Terraform state with the current state in Qrator and then transfer the resource to a managed configuration.
Important considerations during operation
- The provider operates through the Qrator API, so a valid API key is required for connection.
- For local provider development, you can use
dev_overridesin~/.terraformrc. - The repository contains an examples/ directory with ready-made configuration examples,
- which can be used as a starting point.
Useful links
Official provider repository: README, requirements, authentication, resource list.