batonogov/terraform-provider-threexui

Terraform provider for 3x-ui (Xray/VLESS/Reality/WireGuard) — manage inbounds, clients, panel settings, cluster nodes & Xray config as code. GitOps for your VPN panel.

52

stars

376

commits

Go

primary language

Sep 11, 2026

updated

registry.terraform.io/providers/batonogov/threexui
3x-ui
cluster
gitops
hashicorp-terraform
iac
multi-node
reality
self-hosted
shadowsocks
terraform
terraform-provider
trojan
vless
vmess
vpn
wireguard
xray

README

English | فارسی | العربية | 中文 | Español | Русский | Türkçe

Terraform Provider for 3x-ui

Manage 3x-ui inbounds, clients, panel settings, and Xray configuration as code — backup, migrate, and scale your VPN/proxy fleet without clicking through the panel.

CI Terraform Registry Latest Release Go Report Card Go Version Last Commit Codecov License: MIT

Why use it

Running 3x-ui in production means dozens of inbounds, hundreds of clients, and Xray configuration that is easy to break. With this provider you can:

  • Treat configuration as code — your inbound list lives in git, every change is reviewed and versioned.
  • Migrate between servers safely — restore the panel database to preserve IDs and secrets, then verify it with Terraform.
  • Back up Terraform stateterraform state pull exports only Terraform-managed objects; pair it with a panel database backup for disaster recovery.
  • Scale onboarding — add 100 clients in a single PR instead of 100 panel clicks.
  • Plan before prodterraform plan shows exactly what will change before anything ships.

Without vs with the provider

TaskPanel UIThis provider
Add 50 clients50 forms, ~30 seconds eachone for_each, one apply
Migrate to a new servermanual re-entryrestore the panel database, then verify with terraform plan
Audit who has access todayscroll the client listgit log on a .tf file
Roll back a misconfigurationrestore from a JSON backupgit revert + terraform apply
Sync staging ↔ productionexport/import JSON, fix conflictsshared module + per-environment vars
Rotate Reality keys on 10 hostsopen 10 panels, click eachone variable change, one apply

Quick Start

terraform {
  required_providers {
    threexui = {
      source = "batonogov/threexui"
    }
  }
}

provider "threexui" {
  endpoint = "http://localhost:2053"
  username = "admin"
  password = "admin"
}

resource "threexui_inbound" "vless" {
  remark   = "VLESS Reality"
  port     = 443
  protocol = "vless"

  vless_settings {
    decryption = "none"
  }

  stream_settings {
    network  = "tcp"
    security = "reality"
    reality_settings {
      target       = "www.amazon.com:443"
      server_names = ["www.amazon.com"]
    }
  }

  sniffing {
    enabled       = true
    dest_override = ["http", "tls", "quic", "fakedns"]
  }
}

resource "threexui_inbound_client" "client_a" {
  inbound_id = threexui_inbound.vless.id
  email      = "client-a@example.com"
  enable     = true
  flow       = "xtls-rprx-vision"
}

OpenTofu users: use the full registry address:

source = "registry.terraform.io/batonogov/threexui"

The provider is not available in the OpenTofu Registry (why).

Compatibility

Support policy: the provider officially supports every released patch across all supported 3x-ui minor lines — see the compatibility table below. The acceptance matrix exercises each version on every push to main and every pull request.

3x-ui versionStatus
v3.7.0Tested
v3.6.0Tested
v3.5.0Tested
v3.4.2Tested
v3.4.1Tested
v3.4.0Tested
v3.3.1Tested
v3.3.0Tested
v3.2.8Tested
v3.2.7Tested
v3.2.6Tested
v3.2.5Tested
v3.2.0Tested

Newer protocol features are guarded with requireMinVersion and skip automatically on older versions, so the provider runs cleanly across the matrix without per-version forks.

Examples

ExampleDescription
Provider with env configConfigure the provider using supported THREEXUI_* environment variables
Panel userRotate panel administrator credentials
Panel emailConfigure SMTP notifications (v3.4.0+)
Trojan inboundTrojan protocol with WebSocket transport
Shadowsocks inboundShadowsocks with AEAD cipher
Inbound with clientsComplete workflow: inbound + multiple clients
Cluster nodeRegister a remote 3x-ui panel as a cluster node
Host groupManage bulk host routing (v3.5.0+)
Xray observatoryConfigure outbound latency probes (v3.4.2+)
Xray versionPin the installed Xray core version
Multi-server fleetManage many 3x-ui hosts via a reusable module + for_each
Import existing resourcesImport existing 3x-ui resources into Terraform state

Guides

In-repo walkthroughs for common operational scenarios:

Documentation

Full documentation is available on the Terraform Registry.

Resources

ResourceDescription
threexui_inboundInbound proxy (vless, vmess, trojan, shadowsocks, http, mixed, wireguard, amneziawg, tunnel, tun, hysteria, mtproto; TUN 3.2.7+, MTProto 3.3.0+, AmneziaWG 3.7.0+)
threexui_inbound_clientClient within an inbound
threexui_nodeCluster node / multi-node registration
threexui_panel_generalGeneral panel settings
threexui_panel_securitySecurity settings (2FA)
threexui_panel_userAdmin credentials
threexui_panel_telegramTelegram bot integration
threexui_panel_emailSMTP/email notifications (v3.4.0+)
threexui_host_groupHost group routing (multi-host per inbound)
threexui_panel_subscriptionSubscription service settings
threexui_xray_basicsBasic Xray config (log, policy, api, stats)
threexui_xray_dnsDNS servers and hosts
threexui_xray_routingRouting rules
threexui_xray_balancersLoad balancers
threexui_xray_reverseReverse proxy (bridges, portals)
threexui_xray_outboundsOutbound connections
threexui_xray_observatoryXray Observatory / BurstObservatory config
threexui_xray_versionInstalled Xray core version

Data Sources

Data SourceDescription
threexui_inboundsList of all inbounds (JSON, sensitive)
threexui_nodesCluster node tree / multi-node surface (JSON, sensitive)
threexui_server_statusServer status: CPU, memory, disk, uptime (JSON)
threexui_settingsAll panel settings (JSON, sensitive)
threexui_xray_configCurrent Xray template (JSON, sensitive)
threexui_xray_versionsAvailable Xray versions (list of strings)
threexui_online_clientsCurrently online client emails
threexui_client_trafficsClient traffic statistics by email

Security

The provider handles secrets the panel issues automatically (Reality privateKey, WireGuard secretKey, client UUIDs, Telegram bot tokens, LDAP passwords). All such fields are marked Sensitive and never logged in plaintext. See SECURITY.md for the full list and for guidance on protecting your Terraform state.

Development

Requirements

Commands

task build        # Build the provider
task fmt          # Format code (gofmt)
task vet          # Run go vet
task lint         # Run golangci-lint
task pre-commit   # Run all checks manually (fmt, vet, lint, build)
task test:unit    # Run unit tests (no Docker / Terraform needed)
task test:acc     # Run acceptance tests (starts docker compose)
task test         # Run unit + acceptance tests

Local environment

# Start 3x-ui on localhost:2053
docker compose up -d

# Login: admin / admin

# Stop
docker compose down

Contributing

See CONTRIBUTING.md for local setup, testing, and submission guidelines. Bug reports, feature requests, and pull requests are all welcome — and so are notes about which 3x-ui versions you run in production.

Changelog

Releases follow Conventional Commits and are published automatically. See CHANGELOG.md for the full version history.

License

MIT

Contributors

batonogov

270 commits

dependabot[bot]

45 commits

sanchpet

3 commits

batonogov/terraform-provider-threexui

Terraform provider for 3x-ui (Xray/VLESS/Reality/WireGuard) — manage inbounds, clients, panel settings, cluster nodes & Xray config as code. GitOps for your VPN panel.

52

stars

376

commits

Go

primary language

Sep 11, 2026

updated

registry.terraform.io/providers/batonogov/threexui
3x-ui
cluster
gitops
hashicorp-terraform
iac
multi-node
reality
self-hosted
shadowsocks
terraform
terraform-provider
trojan
vless
vmess
vpn
wireguard
xray

README

English | فارسی | العربية | 中文 | Español | Русский | Türkçe

Terraform Provider for 3x-ui

Manage 3x-ui inbounds, clients, panel settings, and Xray configuration as code — backup, migrate, and scale your VPN/proxy fleet without clicking through the panel.

CI Terraform Registry Latest Release Go Report Card Go Version Last Commit Codecov License: MIT

Why use it

Running 3x-ui in production means dozens of inbounds, hundreds of clients, and Xray configuration that is easy to break. With this provider you can:

  • Treat configuration as code — your inbound list lives in git, every change is reviewed and versioned.
  • Migrate between servers safely — restore the panel database to preserve IDs and secrets, then verify it with Terraform.
  • Back up Terraform stateterraform state pull exports only Terraform-managed objects; pair it with a panel database backup for disaster recovery.
  • Scale onboarding — add 100 clients in a single PR instead of 100 panel clicks.
  • Plan before prodterraform plan shows exactly what will change before anything ships.

Without vs with the provider

TaskPanel UIThis provider
Add 50 clients50 forms, ~30 seconds eachone for_each, one apply
Migrate to a new servermanual re-entryrestore the panel database, then verify with terraform plan
Audit who has access todayscroll the client listgit log on a .tf file
Roll back a misconfigurationrestore from a JSON backupgit revert + terraform apply
Sync staging ↔ productionexport/import JSON, fix conflictsshared module + per-environment vars
Rotate Reality keys on 10 hostsopen 10 panels, click eachone variable change, one apply

Quick Start

terraform {
  required_providers {
    threexui = {
      source = "batonogov/threexui"
    }
  }
}

provider "threexui" {
  endpoint = "http://localhost:2053"
  username = "admin"
  password = "admin"
}

resource "threexui_inbound" "vless" {
  remark   = "VLESS Reality"
  port     = 443
  protocol = "vless"

  vless_settings {
    decryption = "none"
  }

  stream_settings {
    network  = "tcp"
    security = "reality"
    reality_settings {
      target       = "www.amazon.com:443"
      server_names = ["www.amazon.com"]
    }
  }

  sniffing {
    enabled       = true
    dest_override = ["http", "tls", "quic", "fakedns"]
  }
}

resource "threexui_inbound_client" "client_a" {
  inbound_id = threexui_inbound.vless.id
  email      = "client-a@example.com"
  enable     = true
  flow       = "xtls-rprx-vision"
}

OpenTofu users: use the full registry address:

source = "registry.terraform.io/batonogov/threexui"

The provider is not available in the OpenTofu Registry (why).

Compatibility

Support policy: the provider officially supports every released patch across all supported 3x-ui minor lines — see the compatibility table below. The acceptance matrix exercises each version on every push to main and every pull request.

3x-ui versionStatus
v3.7.0Tested
v3.6.0Tested
v3.5.0Tested
v3.4.2Tested
v3.4.1Tested
v3.4.0Tested
v3.3.1Tested
v3.3.0Tested
v3.2.8Tested
v3.2.7Tested
v3.2.6Tested
v3.2.5Tested
v3.2.0Tested

Newer protocol features are guarded with requireMinVersion and skip automatically on older versions, so the provider runs cleanly across the matrix without per-version forks.

Examples

ExampleDescription
Provider with env configConfigure the provider using supported THREEXUI_* environment variables
Panel userRotate panel administrator credentials
Panel emailConfigure SMTP notifications (v3.4.0+)
Trojan inboundTrojan protocol with WebSocket transport
Shadowsocks inboundShadowsocks with AEAD cipher
Inbound with clientsComplete workflow: inbound + multiple clients
Cluster nodeRegister a remote 3x-ui panel as a cluster node
Host groupManage bulk host routing (v3.5.0+)
Xray observatoryConfigure outbound latency probes (v3.4.2+)
Xray versionPin the installed Xray core version
Multi-server fleetManage many 3x-ui hosts via a reusable module + for_each
Import existing resourcesImport existing 3x-ui resources into Terraform state

Guides

In-repo walkthroughs for common operational scenarios:

Documentation

Full documentation is available on the Terraform Registry.

Resources

ResourceDescription
threexui_inboundInbound proxy (vless, vmess, trojan, shadowsocks, http, mixed, wireguard, amneziawg, tunnel, tun, hysteria, mtproto; TUN 3.2.7+, MTProto 3.3.0+, AmneziaWG 3.7.0+)
threexui_inbound_clientClient within an inbound
threexui_nodeCluster node / multi-node registration
threexui_panel_generalGeneral panel settings
threexui_panel_securitySecurity settings (2FA)
threexui_panel_userAdmin credentials
threexui_panel_telegramTelegram bot integration
threexui_panel_emailSMTP/email notifications (v3.4.0+)
threexui_host_groupHost group routing (multi-host per inbound)
threexui_panel_subscriptionSubscription service settings
threexui_xray_basicsBasic Xray config (log, policy, api, stats)
threexui_xray_dnsDNS servers and hosts
threexui_xray_routingRouting rules
threexui_xray_balancersLoad balancers
threexui_xray_reverseReverse proxy (bridges, portals)
threexui_xray_outboundsOutbound connections
threexui_xray_observatoryXray Observatory / BurstObservatory config
threexui_xray_versionInstalled Xray core version

Data Sources

Data SourceDescription
threexui_inboundsList of all inbounds (JSON, sensitive)
threexui_nodesCluster node tree / multi-node surface (JSON, sensitive)
threexui_server_statusServer status: CPU, memory, disk, uptime (JSON)
threexui_settingsAll panel settings (JSON, sensitive)
threexui_xray_configCurrent Xray template (JSON, sensitive)
threexui_xray_versionsAvailable Xray versions (list of strings)
threexui_online_clientsCurrently online client emails
threexui_client_trafficsClient traffic statistics by email

Security

The provider handles secrets the panel issues automatically (Reality privateKey, WireGuard secretKey, client UUIDs, Telegram bot tokens, LDAP passwords). All such fields are marked Sensitive and never logged in plaintext. See SECURITY.md for the full list and for guidance on protecting your Terraform state.

Development

Requirements

Commands

task build        # Build the provider
task fmt          # Format code (gofmt)
task vet          # Run go vet
task lint         # Run golangci-lint
task pre-commit   # Run all checks manually (fmt, vet, lint, build)
task test:unit    # Run unit tests (no Docker / Terraform needed)
task test:acc     # Run acceptance tests (starts docker compose)
task test         # Run unit + acceptance tests

Local environment

# Start 3x-ui on localhost:2053
docker compose up -d

# Login: admin / admin

# Stop
docker compose down

Contributing

See CONTRIBUTING.md for local setup, testing, and submission guidelines. Bug reports, feature requests, and pull requests are all welcome — and so are notes about which 3x-ui versions you run in production.

Changelog

Releases follow Conventional Commits and are published automatically. See CHANGELOG.md for the full version history.

License

MIT

Contributors

batonogov

270 commits

dependabot[bot]

45 commits

sanchpet

3 commits

Languages

Go

99.1%