GL.iNet Terraform Provider

I travel with a GL.iNet Slate AX (GL-AXT1800), a small router that sits between my devices and whatever hotel or café Wi-Fi I'm on. It keeps a WireGuard tunnel back to my homelab. My traffic goes through home, and I keep the services I run there, like network-wide ad blocking.

Everything else in my homelab is code. The router was the one box I configured by clicking through a web UI and hoping I'd remember what I did. terraform-provider-glinet fixes that. I describe the router in Terraform or OpenTofu, and a plan shows where the router and the code differ.

provider "glinet" {
  host     = "http://192.168.8.1"
  password = var.glinet_password
}
 
resource "glinet_adguardhome" "this" {
  enabled     = true
  dns_enabled = true
}
 
resource "glinet_fan" "this" {
  temperature = 60
}
 
# Read the POSIX TZ string from this machine's zoneinfo file
# instead of hard-coding daylight saving rules.
data "external" "tz" {
  program = ["sh", "-c", "printf '{\"posix\":\"%s\"}' \"$(tail -n 1 /usr/share/zoneinfo/America/New_York)\""]
}
 
resource "glinet_system_timezone" "this" {
  zone_name = "America/New York"
  timezone  = data.external.tz.result.posix
}
 
# Saves the profile. Starting the tunnel is a separate step.
resource "glinet_wireguard_client_group" "home" {
  name = "home"
}
 
resource "glinet_wireguard_client_config" "home" {
  group_id    = glinet_wireguard_client_group.home.id
  name        = "home server"
  address_v4  = "10.0.0.2/32"
  private_key = var.wireguard_private_key
  public_key  = var.wireguard_server_public_key
  endpoint    = "vpn.example.com:51820"
  allowed_ips = ["0.0.0.0/0", "::/0"]
}

What it does

  • Coverage - Wi-Fi, LAN, WAN and multi-WAN, DNS, the firewall, WireGuard, Tailscale, ZeroTier, AdGuard Home, parental control, and hardware settings like the fan. Resources cover the options that the firmware 4.8.3 web UI offers, not only the ones my router uses. The exceptions are documented.
  • Import - Every resource supports import, so you can adopt a router one setting at a time. Many optional attributes keep the router's current value when you leave them out.
  • Lockout risks - A wrong WAN setting or a Wi-Fi restart can cut off your access. The affected resources carry a warning at the top of their documentation. The provider also rejects a switch to allow-list mode while the allow list is empty.
  • Destroy behavior - Depending on the resource, destroy disables a feature, removes an entry, or leaves the router setting in place. Each resource's documentation says which.
  • Hardware test coverage - Hardware tests ran on a Slate AX with firmware 4.7.0 and 4.8.3. Each resource documents which writes ran on the real router and which ran only against a fake router. The repository also lists what is out of scope, and why.
  • Versioning and CI - Both projects follow semantic versioning from v1.0.0. The provider's CI tests Terraform and OpenTofu.

The client: glinet-client-go

The provider talks to the router through glinet-client-go, a Go library I wrote alongside it. It handles login and session renewal. It has typed methods for most of the router's JSON-RPC API and a generic call for the rest.

client, err := glinet.NewClientWithHost("192.168.8.1", "root", []byte(password))
if err != nil {
	return err
}
 
tz, err := client.System.GetTimezoneConfig(ctx)

The client also ships an in-memory fake router for tests. The provider's default test suite runs against it, and other projects can use it too. The repository keeps saved, redacted responses from the real router, with a report per firmware version that says which writes were verified on hardware.

How I built this

An older version of this page showed an example full of resources I hadn't built.

  1. 2022

    Two repos

    I started the provider and, the same day, a Go client for the router's API, to learn Go and Terraform.

  2. 2023

    Firmware v4 and a few releases

    I rewrote the client for the JSON-RPC API of firmware v4 and shipped a few small releases.

  3. 2026

    v1.0.0

    After more than two years away, I picked it up again with Claude Code. Eight days later, both projects had shipped v1.0.0.

How the AI-assisted development worked

One long Claude Code session ran Claude Fable 5.2 as the orchestrator. It wrote the task briefs, checked the diffs, and opened the pull requests, but wrote almost no code itself. Claude Opus 5.5 subagents implemented the tasks, each in a separate checkout so several could run at once. GitHub Copilot reviewed every pull request, and valid findings went back to the same subagent.

Medirection
  • rules
  • scope
  • decisions
  • release approval
Claude Fable 5.2orchestrator · one long session
  • plans
  • writes briefs
  • checks every diff
  • opens PRs
  • merges
a narrow written brief each
Claude Opus 5.5 subagentsin parallel · one git worktree each
Subagentfirewall rules
  • code
  • tests
  • report
SubagentLAN and Wi-Fi
  • code
  • tests
  • report
Subagentclient methods
  • code
  • tests
  • report
branch and report back to the orchestrator
Pull request
CI
  • build
  • lint
  • fake-router tests
GitHub Copilotreview
  • every pull request
Fixes
  • valid: back to the same subagent
  • wrong: declined with a reason
squash merge
main
before the tag
OpenAI Codexadversarial review of both repos
v1.0.0

At first I approved every push and merge. Later I delegated routine merges and kept the decisions: scope, naming, anything that could affect my router, and the release. I ran each release on my own network, which is where most of my feedback came from. Delegating was only safe because the rules were written down first:

  • No guessing - GL.iNet's official API reference is offline. Router behavior had to be confirmed on the real router. Where that wasn't possible, the write format came from the web UI's code, and the documentation says so.
  • Mock data only - Nothing I configured for myself goes into a public repo, secret or not. Recorded responses are redacted by default. The question for every value is "did I set this?", not "is it on a list?".
  • Writes to the real router - The router sat on my desk with my home Wi-Fi as its uplink. The agents never touched my WireGuard configuration or the uplink, and never wrote while I was away. Several real-router tests go through a local proxy that checks each call before it reaches the router. The reboot schedule test, for example, can only write a disabled schedule.
  • Plan, never apply - In my homelab repo, the agents could run terraform plan. terraform apply needed my permission every time.
  • It's for everyone - The agents audited each resource against the web UI and added the options I don't use.

Bugs, trade-offs, and release decisions

  • Overheating - At one point the router kept dropping off the network, with nothing in the logs. It was sitting in the sun at 70 °C with the fan off, because the fan doesn't start until 75. I lowered the threshold to 60 through the API, and the outages stopped. The web UI only offers 70 to 90 °C. glinet_fan now manages that setting in my own config.
  • A firmware fault - Firmware 4.8.3 accepts a firewall rule without a destination port. It then returns HTTP 500 when you try to change or remove it. The provider can't fix firmware, so it warns during planning. When it sees that failure, it gives you the SSH commands to recover.
  • An update with nothing in it - After I imported my WireGuard config, Terraform showed an update even though the values matched. The imported state lacked the "sensitive" mark that my variable had. It's documented now.
  • Time zone rules - I wanted to set only zone_name, but the router also needs a POSIX TZ string. I could have put a lookup table in the provider, but I didn't love that a country changing its daylight saving rules would require a provider release. So the provider stays dumb, and the consuming Terraform code provides the POSIX string from the machine's zoneinfo file with an external data source, like in the example above.
  • The v1.0.0 upgrade - Before v1.0.0 I approved consistent names for switches, MAC addresses, and allow and block lists. I preferred a clean interface over compatibility with a 0.x release. After I renamed the attributes in my homelab code, a plan against my real state showed no changes.
  • A second opinion - Before tagging, I had OpenAI's Codex (gpt-6.2-sol) review both repositories adversarially. It found that destroying a parental-control group could delete a different group after a rename on the router. It also found a failed router write that could be read as success. Both were fixed before release.
  • Release sequencing - The orchestrator merged release preparation while those fixes were still open. I now leave the version bump and tagging until the fixes are merged. The provider's release workflow also fails unless the tagged commit is on main.

I didn't type most of the code. I decided what it does, what it refuses to do, and what counts as proof that it works.

Two gaps I'd like help with are Wi-Fi 7 multi-link networks and cellular modems. I don't own that hardware, and I won't add support for an API I can't record. If you own one of those models, the issues say what I need. And if you work at GL.iNet and want to send me a router for testing, I won't say no.