diff --git a/docs/index.md b/docs/index.md index f200a6a..08000f9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,43 +1,28 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "haproxy Provider" -subcategory: "" +layout: "" +page_title: "Provider: HAProxy" description: |- - Terraform provider for interacting with HAProxy Dataplane API. + The HAProxy provider provides resources to interact with a HAProxy Dataplane API. --- -# haproxy Provider - -```hcl -# Set the required provider and versions -terraform { - required_providers { - haproxy = { - version = "~> 1.0.0" - source = "matthisholleville/haproxy" - } - } -} +# HAProxy Provider + +The HAProxy provider provides resources to interact with a HAProxy Dataplane API. -# Configure the haproxy provider +## Example Usage + +```terraform provider "haproxy" { - server_addr = "10.100.0.130:5555" - username = "CHANGE_ME" - password = "CHANGE_ME" - insecure = true -} + server_addr = "localhost:5555" # optionally use HAPROXY_SERVER env var + username = "admin" # optionally use HAPROXY_USERNAME env var + password = "adminpwd" # optionally use HAPROXY_PASSWORD env var -# Create a new entrie in the ratelimit HAProxy Maps file -resource "haproxy_maps" "test" { - map = "ratelimit" - key = "/metrics" - value = "50" + # you may need to allow insecure TLS communications unless you have configured + # certificates for your server + insecure = true # optionally use HAPROXY_INSECURE env var } ``` - - - ## Schema @@ -46,4 +31,4 @@ resource "haproxy_maps" "test" { - **insecure** (Boolean) Scheme for request. If not set, https will be use. - **password** (String) Password use for authentification - **server_addr** (String) HAProxy Dataplaneapi server address. -- **username** (String) Username use for authentification +- **username** (String) Username use for authentification \ No newline at end of file diff --git a/docs/resources/frontend.md b/docs/resources/frontend.md index c591d3e..69ba834 100644 --- a/docs/resources/frontend.md +++ b/docs/resources/frontend.md @@ -3,15 +3,20 @@ page_title: "haproxy_frontend Resource - terraform-provider-haproxy" subcategory: "" description: |- - Manage HAProxy frontend - + haproxy_frontend manage frontend. --- # haproxy_frontend (Resource) +`haproxy_frontend` manage frontend. +## Example Usage - +```terraform +resource "haproxy_frontend" "my-frontend" { + name = "my-frontend" +} +``` ## Schema @@ -88,4 +93,11 @@ Optional: - **stats_show_node_name** (String) Enable reporting of a host name on the statistics page. https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-stats%20show-node - **stats_uri_prefix** (String) Enable statistics and define the URI prefix to access them. https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-stats%20uri +## Import + +Import is supported using the following syntax: +```shell +# import from provider configured site +terraform import haproxy_frontend.my-frontend my-frontend +``` diff --git a/docs/resources/maps.md b/docs/resources/maps.md index 72d4457..509dc55 100644 --- a/docs/resources/maps.md +++ b/docs/resources/maps.md @@ -3,15 +3,22 @@ page_title: "haproxy_maps Resource - terraform-provider-haproxy" subcategory: "" description: |- - Manage runtime map files. - + haproxy_maps manage maps. --- # haproxy_maps (Resource) +`haproxy_maps` manage maps. +## Example Usage - +```terraform +resource "haproxy_maps" "my-key" { + map = "ratelimit" + key = "/metrics" + value = "50" +} +``` ## Schema @@ -27,4 +34,11 @@ description: |- - **id** (String) The ID of this resource. - **value** (String) Value name. Default value 'defaultValue' +## Import + +Import is supported using the following syntax: +```shell +# import from provider configured site +terraform import haproxy_maps.my-key map/test/entrie/my-key +``` diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index e3612f4..0000000 --- a/example/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.tfstate -*.tfstate.backup -.terraform -.terraform.lock.hcl \ No newline at end of file diff --git a/example/frontend.tf b/example/frontend.tf deleted file mode 100644 index b14753d..0000000 --- a/example/frontend.tf +++ /dev/null @@ -1,21 +0,0 @@ -locals { - test = [ - "frontend1", - "frontend2", - "frontend3", - "frontend4", - "frontend5", - "frontend6", - "frontend7", - "frontend8", - "frontend9", - "frontend10", - "frontend11", - "frontend12", - "frontend13", - ] -} -resource "haproxy_frontend" "test" { - for_each = { for frontend in local.test : frontend => frontend } - name = each.key -} diff --git a/example/provider.tf b/example/provider.tf deleted file mode 100644 index 9dd578a..0000000 --- a/example/provider.tf +++ /dev/null @@ -1,14 +0,0 @@ -terraform { - required_providers { - haproxy = { - source = "matthisholleville/haproxy" - version = "0.2.0" - } - } -} -provider "haproxy" { - server_addr = "localhost:5555" - username = "admin" - password = "adminpwd" - insecure = true -} diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf new file mode 100644 index 0000000..83b213a --- /dev/null +++ b/examples/provider/provider.tf @@ -0,0 +1,9 @@ +provider "haproxy" { + server_addr = "localhost:5555" # optionally use HAPROXY_SERVER env var + username = "admin" # optionally use HAPROXY_USERNAME env var + password = "adminpwd" # optionally use HAPROXY_PASSWORD env var + + # you may need to allow insecure TLS communications unless you have configured + # certificates for your server + insecure = true # optionally use HAPROXY_INSECURE env var +} diff --git a/examples/resources/haproxy_frontend/import.sh b/examples/resources/haproxy_frontend/import.sh new file mode 100644 index 0000000..63cc675 --- /dev/null +++ b/examples/resources/haproxy_frontend/import.sh @@ -0,0 +1,2 @@ +# import from provider configured site +terraform import haproxy_frontend.my-frontend my-frontend \ No newline at end of file diff --git a/examples/resources/haproxy_frontend/resource.tf b/examples/resources/haproxy_frontend/resource.tf new file mode 100644 index 0000000..3c5c662 --- /dev/null +++ b/examples/resources/haproxy_frontend/resource.tf @@ -0,0 +1,3 @@ +resource "haproxy_frontend" "my-frontend" { + name = "my-frontend" +} diff --git a/examples/resources/haproxy_maps/import.sh b/examples/resources/haproxy_maps/import.sh new file mode 100644 index 0000000..773e57b --- /dev/null +++ b/examples/resources/haproxy_maps/import.sh @@ -0,0 +1,2 @@ +# import from provider configured site +terraform import haproxy_maps.my-key map/test/entrie/my-key \ No newline at end of file diff --git a/example/maps.tf b/examples/resources/haproxy_maps/resource.tf similarity index 63% rename from example/maps.tf rename to examples/resources/haproxy_maps/resource.tf index 539e21c..4681299 100644 --- a/example/maps.tf +++ b/examples/resources/haproxy_maps/resource.tf @@ -1,4 +1,4 @@ -resource "haproxy_maps" "test" { +resource "haproxy_maps" "my-key" { map = "ratelimit" key = "/metrics" value = "50" diff --git a/internal/provider/resource_frontend.go b/internal/provider/resource_frontend.go index aacaf30..a1255a6 100644 --- a/internal/provider/resource_frontend.go +++ b/internal/provider/resource_frontend.go @@ -12,6 +12,7 @@ import ( func resourceFrontend() *schema.Resource { return &schema.Resource{ + Description: "`haproxy_frontend` manage frontend.", CreateContext: resourceFrontendCreate, ReadContext: resourceFrontendRead, UpdateContext: resourceFrontendUpdate, diff --git a/internal/provider/resource_maps.go b/internal/provider/resource_maps.go index f1654c6..2f55b7e 100644 --- a/internal/provider/resource_maps.go +++ b/internal/provider/resource_maps.go @@ -15,6 +15,7 @@ import ( func resourceMaps() *schema.Resource { return &schema.Resource{ + Description: "`haproxy_maps` manage maps.", CreateContext: resourceMapsCreate, ReadContext: resourceMapsRead, UpdateContext: resourceMapsUpdate, diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl new file mode 100644 index 0000000..d94543b --- /dev/null +++ b/templates/index.md.tmpl @@ -0,0 +1,16 @@ +--- +layout: "" +page_title: "Provider: HAProxy" +description: |- + The HAProxy provider provides resources to interact with a HAProxy Dataplane API. +--- + +# HAProxy Provider + +The HAProxy provider provides resources to interact with a HAProxy Dataplane API. + +## Example Usage + +{{tffile "examples/provider/provider.tf"}} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file