Terraform module for deploying an Elastic Load Balancer
This Terraform module Elastic Load Balancer for Flexible Engine cover :
- Listeners configuration TCP/HTTP/HTTPS (With SSL certificate, and whitelist)
- Backends/Pools configuration with members
- Monitoring of backend members
- L7 Policies to redirect HTTP requests to another listener or pool.
module "elb_web" {
source = "FlexibleEngineCloud/elb/flexibleengine"
version = "1.0.0"
loadbalancer_name = "my-http-elb"
subnet_id = "my-subnet-id"
bind_eip = true
cert = true
domain = "my-domain-name.com"
cert_name = "my-cert-name"
certId = "my-cert-id"
vip_address = "192.168.13.148"
listeners = [
{
name = "http"
port = 80
protocol = "HTTP"
hasCert = false
},
{
name = "https"
port = 443
protocol = "TERMINATED_HTTPS"
hasCert = true
}
]
pools = [ {
name = "poolhttp"
protocol = "HTTP"
lb_method = "ROUND_ROBIN"
listener_index = 0
},
{
name = "poolhttps"
protocol = "HTTP"
lb_method = "ROUND_ROBIN"
listener_index = 1
}
]
backends = [
{
name = "backend1"
port = 80
address_index = 0
pool_index = 0
subnet_id = "backend1-subnet-id"
},
{
name = "backend2"
port = 80
address_index = 1
pool_index = 0
subnet_id = "backend2-subnet-id"
},
{
name = "backend3"
port = 443
address_index = 0
pool_index = 1
subnet_id = "backend3-subnet-id"
},
{
name = "backend4"
port = 443
address_index = 1
pool_index = 1
subnet_id = "backend4-subnet-id"
}
]
backends_addresses = ["192.168.13.102","192.168.13.247"]
monitorsHttp = [
{
name = "monitor1"
pool_index = 0
protocol = "HTTP"
delay = 20
timeout = 10
max_retries = 3
url_path = "/check"
http_method = "GET"
expected_codes = "2xx,3xx,4xx"
},
{
name = "monitor2"
pool_index = 1
protocol = "HTTP"
delay = 20
timeout = 10
max_retries = 3
url_path = "/check"
http_method = "GET"
expected_codes = "2xx,3xx,4xx"
}
]
listeners_whitelist = [
{
enable_whitelist = true
whitelist = "192.168.11.1,192.168.0.1/24,192.168.201.18/8"
listeners_index = 0
}
]
}
################################
### Terragrunt Configuration ###
################################
terraform {
source = "terraform-flexibleengine-modules/elb/flexibleengine"
version = "1.0.0"
}
include {
path = find_in_parent_folders()
}
##################
### Parameters ###
##################
inputs = {
loadbalancer_name = "my-http-elb"
subnet_id = "my-subnet-id"
bind_eip = true
cert = true
domain = "my-domain-name.com"
cert_name = "my-cert-name"
certId = "my-cert-id"
vip_address = "192.168.13.148"
listeners = [
{
name = "http"
port = 80
protocol = "HTTP"
hasCert = false
},
{
name = "https"
port = 443
protocol = "TERMINATED_HTTPS"
hasCert = true
}
]
pools = [ {
name = "poolhttp"
protocol = "HTTP"
lb_method = "ROUND_ROBIN"
listener_index = 0
},
{
name = "poolhttps"
protocol = "HTTP"
lb_method = "ROUND_ROBIN"
listener_index = 1
}
]
backends = [
{
name = "backend1"
port = 80
address_index = 0
pool_index = 0
subnet_id = "backend1-subnet-id"
},
{
name = "backend2"
port = 80
address_index = 1
pool_index = 0
subnet_id = "backend2-subnet-id"
},
{
name = "backend3"
port = 443
address_index = 0
pool_index = 1
subnet_id = "backend3-subnet-id"
},
{
name = "backend4"
port = 443
address_index = 1
pool_index = 1
subnet_id = "backend4-subnet-id"
}
]
backends_addresses = ["192.168.13.102","192.168.13.247"]
monitorsHttp = [
{
name = "monitor1"
pool_index = 0
protocol = "HTTP"
delay = 20
timeout = 10
max_retries = 3
url_path = "/check"
http_method = "GET"
expected_codes = "2xx,3xx,4xx"
},
{
name = "monitor2"
pool_index = 1
protocol = "HTTP"
delay = 20
timeout = 10
max_retries = 3
url_path = "/check"
http_method = "GET"
expected_codes = "2xx,3xx,4xx"
}
]
listeners_whitelist = [
{
enable_whitelist = true
whitelist = "192.168.11.1,192.168.0.1/24,192.168.201.18/8"
listeners_index = 0
}
]
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
backends | List of backends | list(object({ |
n/a | yes |
backends_addresses | List of backends adresses | list |
n/a | yes |
bind_eip | Boolean to know if we bind an EIP | bool |
true |
no |
cert | Boolean to know if we add certificate | bool |
false |
no |
certId | n/a | string |
"" |
no |
cert_name | n/a | string |
"" |
no |
certificate | n/a | string |
"" |
no |
domain | n/a | string |
"" |
no |
eip_addr | Address of an existing EIP to attach (ex: 1.2.3.4). Left null will create a new EIP | string |
n/a | yes |
l7policies | List of L7 policies redirected to pools/listeners | list(object({ |
[] |
no |
l7policies_rules | List of L7 policies redirected to pools/listeners | list(object({ |
[] |
no |
listeners | Listeners list | list(object({ |
n/a | yes |
listeners_whitelist | Listeners whitelist | list(object({ |
[] |
no |
loadbalancer_name | Name of the Load Balancer (It is already prefixed by elb-*) | string |
n/a | yes |
monitors | List of monitors | list(object({ |
[] |
no |
monitorsHttp | List of monitors HTTP/HTTPS | list(object({ |
[] |
no |
pools | Pools list | list(object({ |
n/a | yes |
private_key | n/a | string |
"" |
no |
subnet_id | Subnet ID to attach the VIP | string |
n/a | yes |
vip_address | Address of the VIP (In the same Subnet) | string |
n/a | yes |
Name | Description |
---|---|
public_ip | The LB public IP |
private_ip | The LB private IP |