An open API service indexing awesome lists of open source software.

https://github.com/zoro16/terraform-hcloud-load-balancer

Terraform module to provision `Load Balancer` resources in Hetzner Cloud.
https://github.com/zoro16/terraform-hcloud-load-balancer

hetzner hetzner-cloud hetzner-load-balancer terraform-hcloud-load-balancer terraform-module

Last synced: 8 months ago
JSON representation

Terraform module to provision `Load Balancer` resources in Hetzner Cloud.

Awesome Lists containing this project

README

          

## Description

Terraform module to provision `Load Balancer` resources in Hetzner Cloud.

## Usage

```hcl
# Configure the Hetzner Cloud Provider
provider "hcloud" {
token = var.hcloud_token
}

module "net" {
source = "zoro16/network/hcloud"
version = "1.0.0"

create_network = true

network_name = "example-network"
network_ip_cidr_range = "10.100.0.0/16"
network_delete_protection = false
network_expose_routes_to_vswitch = false
network_labels = {
name = "example-network"
environment = "dev"
}
create_subnet = true
subnet_type = "cloud"
subnet_ip_cidr_range = "10.100.0.0/24"
subnet_network_zone = "eu-central"
subnet_network_id = module.net.network_id
}

module "sv1" {
source = "zoro16/server/hcloud"
version = "1.0.0"

create_server = true

server_name = "sv1"
placement_group_name = "sv1"
labels = {
environment = "dev"
product = "lb-servers"
}
}

module "lb" {
source = "../../"

create_load_balancer = true

load_balancer_name = "my-lb"
load_balancer_type = "lb11"
load_balancer_location = "nbg1"
# load_balancer_network_zone = "eu-central"
load_balancer_algorithm_type = "least_connections"
load_balancer_delete_protection = false
load_balancer_labels = {
type = "demo"
environment = "dev"
}

create_load_balancer_network = true
load_balancer_network_load_balancer_id = module.lb.load_balancer_id
# load_balancer_network_network_id = module.net.network_id
# load_balancer_network_ip = "10.100.1.5"
load_balancer_network_subnet_id = module.net.subnet_id
load_balancer_network_enable_public_interface = true

create_load_balancer_target = true
load_balancer_target_type = "label_selector"
load_balancer_target_load_balancer_id = module.lb.load_balancer_id
# load_balancer_target_server_id = module.sv1.server_id
load_balancer_target_label_selector = "product=lb-servers"
# load_balancer_target_ip = "142.142.142.142"
# load_balancer_target_use_private_ip = true

create_load_balancer_service = true
load_balancer_service_load_balancer_id = module.lb.load_balancer_id
load_balancer_service_protocol = "http"
load_balancer_service_listen_port = 80
load_balancer_service_destination_port = 80
load_balancer_service_proxyprotocol = false
load_balancer_service_http = [
{
sticky_sessions = false
cookie_name = "HCLBSTICKY"
cookie_lifetime = 300
certificates = []
redirect_http = false
}
]
load_balancer_service_health_check = [
{
protocol = "http"
port = 80
interval = 5
timeout = 10
retries = 10
http = [
{
domain = "example.com"
path = "/healthz"
response = "Ok"
tls = false
status_codes = ["200", "201"]
}
]
}
]

}
```

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.2.0 |
| [hcloud](#requirement\_hcloud) | >= 1.49.1 |

## Providers

| Name | Version |
|------|---------|
| [hcloud](#provider\_hcloud) | >= 1.49.1 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [hcloud_load_balancer.load_balancer](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/load_balancer) | resource |
| [hcloud_load_balancer_network.lb_net](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/load_balancer_network) | resource |
| [hcloud_load_balancer_service.lb_service](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/load_balancer_service) | resource |
| [hcloud_load_balancer_target.lb_target](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/load_balancer_target) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [create\_load\_balancer](#input\_create\_load\_balancer) | Whether to create a Load Balancer or not. | `bool` | `false` | no |
| [create\_load\_balancer\_network](#input\_create\_load\_balancer\_network) | Whether to create a Load Balancer Network or not. | `bool` | `false` | no |
| [create\_load\_balancer\_service](#input\_create\_load\_balancer\_service) | Whether to create a Load Balancer Service or not. | `bool` | `false` | no |
| [create\_load\_balancer\_target](#input\_create\_load\_balancer\_target) | Whether to create a Load Balancer Target or not. | `bool` | `false` | no |
| [load\_balancer\_algorithm\_type](#input\_load\_balancer\_algorithm\_type) | Configuration of the algorithm the Load Balancer use.
algorithm support the following fields:
type - (Required, string) Type of the Load Balancer Algorithm. round\_robin or least\_connections | `string` | `"round_robin"` | no |
| [load\_balancer\_delete\_protection](#input\_load\_balancer\_delete\_protection) | Enable or disable delete protection. | `bool` | `false` | no |
| [load\_balancer\_labels](#input\_load\_balancer\_labels) | User-defined labels (key-value pairs) should be created with. | `map(any)` | `{}` | no |
| [load\_balancer\_location](#input\_load\_balancer\_location) | The location name of the Load Balancer. Require when no network\_zone is set. | `string` | `"nbg1-dc3"` | no |
| [load\_balancer\_name](#input\_load\_balancer\_name) | Name of the Load Balancer. | `string` | `null` | no |
| [load\_balancer\_network\_enable\_public\_interface](#input\_load\_balancer\_network\_enable\_public\_interface) | Enable or disable the Load Balancers public interface. | `bool` | `true` | no |
| [load\_balancer\_network\_ip](#input\_load\_balancer\_network\_ip) | IP to request to be assigned to this Load Balancer. If you do not provide this then you will be auto assigned an IP address. | `string` | `null` | no |
| [load\_balancer\_network\_load\_balancer\_id](#input\_load\_balancer\_network\_load\_balancer\_id) | ID of the Load Balancer. | `number` | `null` | no |
| [load\_balancer\_network\_network\_id](#input\_load\_balancer\_network\_network\_id) | ID of the network which should be added to the Load Balancer. Required if `subnet_id` is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using `network_id` will not create an explicit dependency between the Load Balancer and the subnet. Therefore `depends_on` may need to be used. Alternatively the `subnet_id` property can be used, which will create an explicit dependency between `hcloud_load_balancer_network` and the existence of a subnet. | `number` | `null` | no |
| [load\_balancer\_network\_subnet\_id](#input\_load\_balancer\_network\_subnet\_id) | ID of the sub-network which should be added to the Load Balancer. Required if `network_id` is not set. Note: if the `ip` property is missing, the Load Balancer is currently added to the last created subnet. | `string` | `null` | no |
| [load\_balancer\_network\_zone](#input\_load\_balancer\_network\_zone) | The Network Zone of the Load Balancer. Require when no location is set. | `string` | `"eu-central"` | no |
| [load\_balancer\_service\_destination\_port](#input\_load\_balancer\_service\_destination\_port) | Port the service connects to the targets on, required if protocol is tcp. Can be everything between 1 and 65535. | `number` | `80` | no |
| [load\_balancer\_service\_health\_check](#input\_load\_balancer\_service\_health\_check) | List of health check configurations when protocol is http or https. |

list(object({
# (Required) Protocol the health check uses. http or tcp
protocol = optional(string)

# (Required) Port the health check tries to connect to, required if protocol is tcp. Can be everything between 1 and 65535. Must be unique per Load Balancer.
port = optional(number)

# (Required)Interval how often the health check will be performed, in seconds.
interval = optional(number)

# (Required) Timeout when a health check try will be canceled if there is no response, in seconds.
timeout = optional(number)

# Number of tries a health check will be performed until a target will be listed as unhealthy.
retries = optional(number)

# List of http configurations. Required if protocol is http.
http = optional(list(object({
# Domain we try to access when performing the Health Check.
domain = optional(string)

# Path we try to access when performing the Health Check.
path = optional(string)

# Response we expect to be included in the Target response when a Health Check was performed.
response = optional(string)

# Enable TLS certificate checking.
tls = optional(bool)

# We expect that the target answers with these status codes. If not the target is marked as unhealthy.
status_codes = optional(list(string))
})))

}))
| `null` | no |
| [load\_balancer\_service\_http](#input\_load\_balancer\_service\_http) | List of http configurations when protocol is http or https. |
list(object({
# Enable sticky sessions
sticky_sessions = optional(bool)

# Name of the cookie for sticky session. Default: HCLBSTICKY
cookie_name = optional(string)

# Lifetime of the cookie for sticky session (in seconds). Default: 300
cookie_lifetime = optional(number)

# List of IDs from certificates which the Load Balancer has.
certificates = optional(list(number))

# Redirect HTTP to HTTPS traffic. Only supported for services with protocol https using the default HTTP port 80.
redirect_http = optional(bool)

}))
| `null` | no |
| [load\_balancer\_service\_listen\_port](#input\_load\_balancer\_service\_listen\_port) | Port the service listen on, required if protocol is tcp. Can be everything between 1 and 65535. Must be unique per Load Balancer. | `number` | `80` | no |
| [load\_balancer\_service\_load\_balancer\_id](#input\_load\_balancer\_service\_load\_balancer\_id) | Id of the load balancer this service belongs to. | `string` | `null` | no |
| [load\_balancer\_service\_protocol](#input\_load\_balancer\_service\_protocol) | Protocol of the service. http, https or tcp | `string` | `"http"` | no |
| [load\_balancer\_service\_proxyprotocol](#input\_load\_balancer\_service\_proxyprotocol) | Whether to enable proxyprotocol or not. | `bool` | `false` | no |
| [load\_balancer\_target\_ip](#input\_load\_balancer\_target\_ip) | IP address for an IP Target. Required if type is ip. | `string` | `null` | no |
| [load\_balancer\_target\_label\_selector](#input\_load\_balancer\_target\_label\_selector) | Label Selector selecting targets for this Load Balancer. Required if type is label\_selector. | `string` | `null` | no |
| [load\_balancer\_target\_load\_balancer\_id](#input\_load\_balancer\_target\_load\_balancer\_id) | ID of the Load Balancer to which the target gets attached. | `string` | `null` | no |
| [load\_balancer\_target\_server\_id](#input\_load\_balancer\_target\_server\_id) | ID of the server which should be a target for this Load Balancer. Required if type is server | `number` | `null` | no |
| [load\_balancer\_target\_type](#input\_load\_balancer\_target\_type) | Type of the target. Possible values `server`, `label_selector`, `ip`."
`server` => VM Server
`label_selector` => All servers that match this label query will be used as a target.
`ip` => Dedicated Server (root) IP address | `string` | `"server"` | no |
| [load\_balancer\_target\_use\_private\_ip](#input\_load\_balancer\_target\_use\_private\_ip) | Use the private IP to connect to Load Balancer targets. Only allowed if type is server or label\_selector. | `bool` | `null` | no |
| [load\_balancer\_type](#input\_load\_balancer\_type) | Type of the Load Balancer. | `string` | `"lb11"` | no |

## Outputs

| Name | Description |
|------|-------------|
| [load\_balancer\_algorithm](#output\_load\_balancer\_algorithm) | Configuration of the algorithm the Load Balancer use. |
| [load\_balancer\_delete\_protection](#output\_load\_balancer\_delete\_protection) | Enable or disable delete protection. |
| [load\_balancer\_first\_network\_id](#output\_load\_balancer\_first\_network\_id) | ID of the first private network that this Load Balancer is connected to. |
| [load\_balancer\_first\_network\_ip](#output\_load\_balancer\_first\_network\_ip) | IP of the Load Balancer in the first private network that it is connected to. |
| [load\_balancer\_id](#output\_load\_balancer\_id) | Unique ID of the Load Balancer. |
| [load\_balancer\_ipv4](#output\_load\_balancer\_ipv4) | IPv4 Address of the Load Balancer. |
| [load\_balancer\_ipv6](#output\_load\_balancer\_ipv6) | IPv6 Address of the Load Balancer. |
| [load\_balancer\_labels](#output\_load\_balancer\_labels) | User-defined labels (key-value pairs) should be created with. |
| [load\_balancer\_location](#output\_load\_balancer\_location) | The location name of the Load Balancer. Require when no network\_zone is set. |
| [load\_balancer\_name](#output\_load\_balancer\_name) | Name of the Load Balancer. |
| [load\_balancer\_network\_id](#output\_load\_balancer\_network\_id) | ID of the Load Balancer network. |
| [load\_balancer\_network\_load\_balancer\_id](#output\_load\_balancer\_network\_load\_balancer\_id) | ID of the Load Balancer. |
| [load\_balancer\_network\_network\_id](#output\_load\_balancer\_network\_network\_id) | ID of the network. |
| [load\_balancer\_network\_network\_ip](#output\_load\_balancer\_network\_network\_ip) | IP assigned to this Load Balancer. |
| [load\_balancer\_service\_destination\_port](#output\_load\_balancer\_service\_destination\_port) | Port the service connects to the targets on, required if protocol is tcp. Can be everything between 1 and 65535. |
| [load\_balancer\_service\_health\_check](#output\_load\_balancer\_service\_health\_check) | List of health check configurations when protocol is http or https. |
| [load\_balancer\_service\_http](#output\_load\_balancer\_service\_http) | List of http configurations when protocol is http or https. |
| [load\_balancer\_service\_listen\_port](#output\_load\_balancer\_service\_listen\_port) | Port the service listen on, required if protocol is tcp. Can be everything between 1 and 65535. Must be unique per Load Balancer. |
| [load\_balancer\_service\_protocol](#output\_load\_balancer\_service\_protocol) | Protocol of the service. http, https or tcp |
| [load\_balancer\_service\_proxyprotocol](#output\_load\_balancer\_service\_proxyprotocol) | Whether to enable proxyprotocol or not. |
| [load\_balancer\_target\_ip](#output\_load\_balancer\_target\_ip) | IP address for an IP Target. Required if type is ip. |
| [load\_balancer\_target\_label\_selector](#output\_load\_balancer\_target\_label\_selector) | Label Selector selecting targets for this Load Balancer. Required if type is label\_selector. |
| [load\_balancer\_target\_server\_id](#output\_load\_balancer\_target\_server\_id) | ID of the server which should be a target for this Load Balancer. Required if type is server |
| [load\_balancer\_target\_type](#output\_load\_balancer\_target\_type) | Type of the target. Possible values `server`, `label_selector`, `ip`. |
| [load\_balancer\_target\_use\_private\_ip](#output\_load\_balancer\_target\_use\_private\_ip) | Use the private IP to connect to Load Balancer targets. Only allowed if type is server or label\_selector. |
| [load\_balancer\_type](#output\_load\_balancer\_type) | Type of the Load Balancer. |