# Terraform provider

> Describe servers, networks, load balancers and Shield rules as code with Terraform or OpenTofu.

Source: https://docs.avenlith.com/en/terraform  
Category: API & automation  
Last updated: 2026-09-22

## Configure

Export an API token and declare the provider:

```hcl
terraform {
  required_providers {
    avenlith = { source = "avenlith/avenlith", version = "~> 2.4" }
  }
}

resource "avenlith_server" "web" {
  count  = 2
  name   = "web-0${count.index + 1}"
  plan   = "vps-pro"
  region = "ist1"
  image  = "ubuntu-26.04"
  labels = { role = "web" }
}

resource "avenlith_load_balancer" "web" {
  name    = "web-lb"
  region  = "ist1"
  targets = avenlith_server.web[*].id
}
```

`terraform init && terraform apply` creates two servers and a load balancer in Istanbul.

## Resources

`avenlith_server`, `avenlith_network`, `avenlith_firewall`, `avenlith_load_balancer`, `avenlith_floating_ip`, `avenlith_k8s_cluster`, `avenlith_db_cluster`, `avenlith_bucket`, `avenlith_shield_rule` and `avenlith_dns_record`.

> **Note:** > The provider works with OpenTofu 1.8+ without changes.

## Remote state

Store state in Avenlith object storage using the `s3` backend with `skip_credentials_validation = true` and the regional endpoint.
