This repository contains the Terraform provider that manages BunkerWeb services through the BunkerWeb HTTP API. The provider is implemented with the Terraform Plugin Framework and exposes the core building blocks needed to model BunkerWeb workloads in code:
bunkerweb_serviceresource for creating, updating, and deleting services.bunkerweb_instanceresource for registering and managing control-plane instances.bunkerweb_global_config_settingresource for enforcing individual control-plane settings.bunkerweb_configresource for authoring API-managed configuration snippets.bunkerweb_banresource for orchestrating bans across instances.bunkerweb_servicedata source for reading existing services.bunkerweb_global_configdata source for inspecting control-plane defaults.bunkerweb_plugins,bunkerweb_cache, andbunkerweb_jobsdata sources for observing UI plugins, cached artefacts, and scheduled jobs.bunkerweb_service_snapshotephemeral resource for capturing service state during a plan.bunkerweb_run_jobsephemeral resource for triggering scheduler jobs on demand.bunkerweb_instance_actionephemeral resource for pinging, reloading, stopping, or deleting instances.bunkerweb_service_convertephemeral resource for toggling services between draft and online states.bunkerweb_config_upload,bunkerweb_config_upload_update, andbunkerweb_config_bulk_deleteephemerals for batch config uploads, file-based edits, and clean-up operations.provider::bunkerweb::service_identifierfunction that normalizes server names into API identifiers.
provider "bunkerweb" {
api_endpoint = "https://127.0.0.1:8888"
api_token = var.bunkerweb_token
}
resource "bunkerweb_service" "app" {
server_name = "app.example.com"
variables = {
upstream = "10.0.0.12"
mode = "production"
}
}Refer to the examples/ directory and the generated docs in docs/ for additional usage patterns.
go install ./...The compiled provider binary will be placed in $GOBIN ($GOPATH/bin by default).
For local development and testing against a live BunkerWeb instance:
# Quick start - automated workflow
cd test-local
./test-provider.sh
# Or manually
go build -o terraform-provider-bunkerweb
cp terraform-provider-bunkerweb ~/.terraform.d/plugins/local/bunkerity/bunkerweb/0.0.1/linux_amd64/terraform-provider-bunkerweb_v0.0.1
cd test-local
terraform init
terraform planSee the test-local/ directory for comprehensive integration tests that validate all provider functionality against a live BunkerWeb API.
Run the full unit test suite with:
go test ./...Acceptance-style tests exercise the provider against a local in-memory API defined in internal/provider/test_server_test.go, so they are safe to run without contacting a live BunkerWeb instance.
The test-local/ directory contains a comprehensive test suite with 22 tests covering:
- All data sources (global_config, plugins, jobs, cache, service, configs)
- All resources (instance, service, global_config_setting, config, ban, plugin)
- All ephemeral resources (snapshots, actions, conversions, uploads, jobs)
- All functions (service_identifier)
Quick reference: cd test-local && ./quick-ref.sh
The repository uses terraform-plugin-docs. Regenerate documentation after schema changes:
make generateIssues and pull requests are welcome. Please ensure new changes include appropriate unit tests and updates to the docs/examples when applicable.