Overview
Terraform replaces manual steps in the CDB Technical Web Portal with version-controlled configuration files. Describe the desired infrastructure once, and Terraform creates, updates, or deletes Cloud and CDN resources automatically through the CDB API.
CDB provider
A provider is a plugin that translates Terraform configuration into API calls — it defines the resource types available for use, such as Virtual Machines, networks, and DNS zones. Two major versions of the CDB provider are published; the right one depends on whether the project is new or existing:
| v2 | v0 | |
|---|---|---|
| Authentication | api_key | permanent_api_token |
| Terraform CLI | >= 1.11 | >= 0.13.0 |
| API coverage | Tracks CDB API automatically | Manual updates |
| Recommended for | New projects | Existing projects |
Specify the version in the configuration to avoid unintended upgrades — v0 and v2 use different, incompatible configuration formats.
Provider configuration
Install Terraform first, then add the provider block to main.tf:
Provider v2 uses api_key for authentication and is auto-generated from the CDB OpenAPI specification.
terraform {
required_version = ">= 1.11"
required_providers {
gcore = {
source = "G-Core/gcore"
version = "~> 2.0"
}
}
}
provider "gcore" {
api_key = "YOUR_API_KEY"
}
Replace YOUR_API_KEY with an API token. For existing v0 projects, follow the migration guide to move to v2.
Manage CDB resources
The v0 provider supports Cloud resources — Virtual Machines, Bare Metal servers, Kubernetes clusters, Load Balancers, and networks — CDN resources, and WAAP resources — domains, security policies, and rules. For v2, the full resource reference is on the Terraform Registry.