/terraform-provider-haproxy-pf

A Terraform provider for HAproxy

Primary LanguageGoMozilla Public License 2.0MPL-2.0

Terraform Provider Haproxy

This provider uses Haproxy Dataplane api in order to manage Terraform objects.

Built with Terraform plugin framework.

Checklist:

  • Backend
  • Frontend
  • Bind
  • Server
  • Server Template

TODO:

  • ACL
  • More resource options

Dev Build provider

set terraformrc file with dev_overrides

# ~/.terraformrc 
provider_installation {

  dev_overrides {
      "registry.terraform.io/marcomezzaro/haproxy-pf" = "<GOPATH>/bin/"
  }

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}

Run the following command to build the provider

$ make install

build and run haproxy for testing

podman build -t haproxy-dp -f docker/Dockerfile docker/
podman run -it --rm -p 5555:5555 --name haproxy localhost/haproxy-dp:latest

Run ACC Test

TF_ACC=1 HAPROXY_SERVER="localhost:5555" HAPROXY_USERNAME="admin" HAPROXY_PASSWORD="adminpwd" HAPROXY_INSECURE="true" go test -v -cover -count 1 ./haproxy/

Generate doc

go generate ./...

Test sample configuration

First, build and install the provider.

$ make install

Then, navigate to the examples directory. and use the example to create terraform manifests

$ cd examples

Run the following command to initialize the workspace and apply the sample configuration.

$ terraform init && terraform apply

Special Thanks

https://github.com/matthisholleville