Terraform Provider
Install and configure the DevZero Terraform provider.
Terraform Provider
The DevZero Terraform provider manages clusters, teams, workload policies, and node policies via HCL. There is also a Terraform module (devzero-inc/cluster/devzero) for one-step cluster setup including operator installation.
Provider Configuration
Add the DevZero provider to your required_providers block and configure it:
terraform {
required_providers {
devzero = {
source = "devzero-inc/devzero"
version = ">= 0.3.0"
}
}
}
provider "devzero" {
team_id = var.devzero_team_id
token = var.devzero_token
}Authentication
| Parameter | Environment Variable | Required | Description |
|---|---|---|---|
team_id | DEVZERO_TEAM_ID | Yes | Your team or organization ID |
token | DEVZERO_TOKEN | Yes (sensitive) | A service account token (dzs-), or a personal access token |
url | DEVZERO_URL | No | API endpoint (default: https://dakr.devzero.io) |
Use a service account token. A service account belongs to the team, not to a person, so its tokens keep working when people leave the team. A team Admin creates one under Settings > Organization Settings > Service Accounts: Create service account, then Manage tokens > Create token on the account. The token starts with dzs- and is shown once.
A personal access token from User Settings still works, but drive devzero_team with a service account token: with a person's token, destroying a devzero_team is that person's leave of the team.
Your team ID is under Settings > Organization Settings > Account > Team ID. Only team Admins see the Account and Service Accounts pages.
Cluster Module
For a quick way to register a cluster and install DevZero operators in one step, use the devzero-inc/cluster/devzero module:
module "devzero_cluster" {
source = "devzero-inc/cluster/devzero"
version = "~> 0.2"
cluster_name = "my-cluster"
}This module handles cluster registration and operator installation automatically. It needs the helm (3.0.2 or later) and kubernetes providers, configured for the cluster. Module 0.2.0 needs provider 0.3.0 or later and takes a team_id input, which registers the cluster in another team, such as a customer's team started with devzero_team. Left out, the cluster registers in the provider's team. See Clusters.
Workflow
terraform init # Download the provider
terraform plan # Preview changes
terraform apply # Apply changesResources
The provider manages the following resources:
- Clusters -- register Kubernetes clusters with DevZero
- Teams -- start a team for a customer from a partner team
- Workload Policies -- configure workload rightsizing rules and attach them to clusters
- Node Policies -- configure Karpenter-based node provisioning