Guides / Access and automation

Manage Etorm with OpenTofu

If you already keep infrastructure in OpenTofu or Terraform, you can keep Etorm in the same files. The provider etorm/etorm manages the same objects as kubectl, with plans and drift detection.

1. Build the provider and register it

You build the provider from source and point OpenTofu at it with a development override.

cd providers/tofu && cargo build --release
# ~/.tofurc (or the file named by TF_CLI_CONFIG_FILE)
provider_installation {
  dev_overrides { "etorm/etorm" = "/path/to/etorm/providers/tofu/target/release" }
  direct {}
}

2. Point the provider at the API

The provider reads its settings from the environment. Keep the token there, out of the .tf files and out of version control.

export ETORM_ENDPOINT=https://api.etorm.com
export ETORM_CLUSTER_HOST_SUFFIX=-api.etorm.com
export ETORM_TOKEN=etorm.root.…   # a token, never in the .tf files

3. Describe your network

terraform {
  required_providers { etorm = { source = "etorm/etorm" } }
}
provider "etorm" {}

resource "etorm_billing_account" "acme" {
  name          = "acme"
  display_name  = "Acme Inc"
  contact_email = "billing@acme.example"
}

resource "etorm_project" "prod" {
  name            = "acme-prod"
  billing_account = etorm_billing_account.acme.name
}

resource "etorm_vpc" "lan" {
  project = etorm_project.prod.name
  name    = "lan"
  cidr    = "10.20.0.0/24"   # leave out for an IPv6-only VPC
}

resource "etorm_account" "laptop" {
  project    = etorm_project.prod.name
  name       = "laptop"
  vpc        = etorm_vpc.lan.name
  public_key = "<WireGuard public key>"
}

resource "etorm_dns_service" "dns" {
  project = etorm_project.prod.name
  name    = "dns"
  vpc     = etorm_vpc.lan.name
  zone    = "corp.test"
  records = [{ name = "www", type = "CNAME", value = "laptop.corp.test", ttl = 300 }]
}

Run tofu plan and tofu apply. The provider waits until each object is no longer Pending, for up to two minutes. If an object ends up Failed, the condition's message comes back as the error. A complete example with DHCP, reservations and outputs is in providers/tofu/examples/main.tf.

Replacements, imports and what the provider covers

Clean up

tofu destroy

OpenTofu deletes the resources in dependency order, so accounts go before their VPC.

Next

Describe a network as a diagram.