|  | 
|  | 1 | +--- | 
|  | 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs | 
|  | 3 | +page_title: "stackit_loadbalancer Resource - stackit" | 
|  | 4 | +subcategory: "" | 
|  | 5 | +description: |- | 
|  | 6 | +  Setting up supporting infrastructure | 
|  | 7 | +  Configuring an OpenStack provider | 
|  | 8 | +  To automate the creation of load balancers, OpenStack can be used to setup the supporting infrastructure. | 
|  | 9 | +  To set up the OpenStack provider, you can create a token through the STACKIT Portal, in your project's Infrastructure API page. | 
|  | 10 | +  There, the OpenStack user domain name, username, and password are generated and can be obtained. The provider can then be configured as follows: | 
|  | 11 | +  ```terraform | 
|  | 12 | +  terraform { | 
|  | 13 | +      required_providers { | 
|  | 14 | +          (...) | 
|  | 15 | +          openstack = { | 
|  | 16 | +              source = "terraform-provider-openstack/openstack" | 
|  | 17 | +          } | 
|  | 18 | +      } | 
|  | 19 | +  } | 
|  | 20 | +  provider "openstack" { | 
|  | 21 | +      userdomainname = "{OpenStack user domain name}" | 
|  | 22 | +      username        = "{OpenStack username}" | 
|  | 23 | +      password         = "{OpenStack password}" | 
|  | 24 | +      region           = "RegionOne" | 
|  | 25 | +      authurl         = "https://keystone.api.iaas.eu01.stackit.cloud/v3" | 
|  | 26 | +  } | 
|  | 27 | +  ``` | 
|  | 28 | +  Configuring the supporting infrastructure | 
|  | 29 | +  The example below uses OpenStack to create the network, router, a public IP address and a compute instance. | 
|  | 30 | +--- | 
|  | 31 | + | 
|  | 32 | +# stackit_loadbalancer (Resource) | 
|  | 33 | + | 
|  | 34 | +## Setting up supporting infrastructure | 
|  | 35 | + | 
|  | 36 | + | 
|  | 37 | +### Configuring an OpenStack provider | 
|  | 38 | + | 
|  | 39 | + | 
|  | 40 | +To automate the creation of load balancers, OpenStack can be used to setup the supporting infrastructure. | 
|  | 41 | +To set up the OpenStack provider, you can create a token through the STACKIT Portal, in your project's Infrastructure API page. | 
|  | 42 | +There, the OpenStack user domain name, username, and password are generated and can be obtained. The provider can then be configured as follows: | 
|  | 43 | +```terraform | 
|  | 44 | +terraform { | 
|  | 45 | +	required_providers { | 
|  | 46 | +		(...) | 
|  | 47 | +		openstack = { | 
|  | 48 | +			source = "terraform-provider-openstack/openstack" | 
|  | 49 | +		} | 
|  | 50 | +	} | 
|  | 51 | +} | 
|  | 52 | +
 | 
|  | 53 | +provider "openstack" { | 
|  | 54 | +	user_domain_name = "{OpenStack user domain name}" | 
|  | 55 | +	user_name        = "{OpenStack username}" | 
|  | 56 | +	password         = "{OpenStack password}" | 
|  | 57 | +	region           = "RegionOne" | 
|  | 58 | +	auth_url         = "https://keystone.api.iaas.eu01.stackit.cloud/v3" | 
|  | 59 | +} | 
|  | 60 | +
 | 
|  | 61 | +``` | 
|  | 62 | +		 | 
|  | 63 | +### Configuring the supporting infrastructure | 
|  | 64 | + | 
|  | 65 | +The example below uses OpenStack to create the network, router, a public IP address and a compute instance. | 
|  | 66 | + | 
|  | 67 | +## Example Usage | 
|  | 68 | + | 
|  | 69 | +```terraform | 
|  | 70 | +# Create a network | 
|  | 71 | +resource "openstack_networking_network_v2" "example" { | 
|  | 72 | +  name = "example-network" | 
|  | 73 | +} | 
|  | 74 | +
 | 
|  | 75 | +# Create a subnet | 
|  | 76 | +resource "openstack_networking_subnet_v2" "example" { | 
|  | 77 | +  name            = "example-subnet" | 
|  | 78 | +  cidr            = "192.168.0.0/25" | 
|  | 79 | +  dns_nameservers = ["8.8.8.8"] | 
|  | 80 | +  network_id      = openstack_networking_network_v2.example.id | 
|  | 81 | +} | 
|  | 82 | +
 | 
|  | 83 | +# Get public network | 
|  | 84 | +data "openstack_networking_network_v2" "public" { | 
|  | 85 | +  name = "floating-net" | 
|  | 86 | +} | 
|  | 87 | +
 | 
|  | 88 | +# Create a floating IP | 
|  | 89 | +resource "openstack_networking_floatingip_v2" "example" { | 
|  | 90 | +  pool = data.openstack_networking_network_v2.public.name | 
|  | 91 | +} | 
|  | 92 | +
 | 
|  | 93 | +# Get flavor for instance | 
|  | 94 | +data "openstack_compute_flavor_v2" "example" { | 
|  | 95 | +  name = "g1.1" | 
|  | 96 | +} | 
|  | 97 | +
 | 
|  | 98 | +# Create an instance | 
|  | 99 | +resource "openstack_compute_instance_v2" "example" { | 
|  | 100 | +  depends_on      = [openstack_networking_subnet_v2.example] | 
|  | 101 | +  name            = "example-instance" | 
|  | 102 | +  flavor_id       = data.openstack_compute_flavor_v2.example.id | 
|  | 103 | +  admin_pass      = "example" | 
|  | 104 | +  security_groups = ["default"] | 
|  | 105 | +
 | 
|  | 106 | +  block_device { | 
|  | 107 | +    uuid                  = "4364cdb2-dacd-429b-803e-f0f7cfde1c24" // Ubuntu 22.04 | 
|  | 108 | +    volume_size           = 32 | 
|  | 109 | +    source_type           = "image" | 
|  | 110 | +    destination_type      = "volume" | 
|  | 111 | +    delete_on_termination = true | 
|  | 112 | +  } | 
|  | 113 | +
 | 
|  | 114 | +  network { | 
|  | 115 | +    name = openstack_networking_network_v2.example.name | 
|  | 116 | +  } | 
|  | 117 | +} | 
|  | 118 | +
 | 
|  | 119 | +# Create a router and attach it to the public network | 
|  | 120 | +resource "openstack_networking_router_v2" "example" { | 
|  | 121 | +  name                = "example-router" | 
|  | 122 | +  admin_state_up      = "true" | 
|  | 123 | +  external_network_id = data.openstack_networking_network_v2.public.id | 
|  | 124 | +} | 
|  | 125 | +
 | 
|  | 126 | +# Attach the subnet to the router | 
|  | 127 | +resource "openstack_networking_router_interface_v2" "example_interface" { | 
|  | 128 | +  router_id = openstack_networking_router_v2.example.id | 
|  | 129 | +  subnet_id = openstack_networking_subnet_v2.example.id | 
|  | 130 | +} | 
|  | 131 | +
 | 
|  | 132 | +# Create a load balancer | 
|  | 133 | +resource "stackit_loadbalancer" "example" { | 
|  | 134 | +  project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | 
|  | 135 | +  name       = "example-load-balancer" | 
|  | 136 | +  target_pools = [ | 
|  | 137 | +    { | 
|  | 138 | +      name        = "example-target-pool" | 
|  | 139 | +      target_port = 80 | 
|  | 140 | +      targets = [ | 
|  | 141 | +        { | 
|  | 142 | +          display_name = "example-target" | 
|  | 143 | +          ip           = openstack_compute_instance_v2.example.network.0.fixed_ip_v4 | 
|  | 144 | +        } | 
|  | 145 | +      ] | 
|  | 146 | +      active_health_check = { | 
|  | 147 | +        healthy_threshold   = 10 | 
|  | 148 | +        interval            = "3s" | 
|  | 149 | +        interval_jitter     = "3s" | 
|  | 150 | +        timeout             = "3s" | 
|  | 151 | +        unhealthy_threshold = 10 | 
|  | 152 | +      } | 
|  | 153 | +    } | 
|  | 154 | +  ] | 
|  | 155 | +  listeners = [ | 
|  | 156 | +    { | 
|  | 157 | +      display_name = "example-listener" | 
|  | 158 | +      port         = 80 | 
|  | 159 | +      protocol     = "PROTOCOL_TCP" | 
|  | 160 | +      target_pool  = "example-target-pool" | 
|  | 161 | +    } | 
|  | 162 | +  ] | 
|  | 163 | +  networks = [ | 
|  | 164 | +    { | 
|  | 165 | +      network_id = openstack_networking_network_v2.example.id | 
|  | 166 | +      role       = "ROLE_LISTENERS_AND_TARGETS" | 
|  | 167 | +    } | 
|  | 168 | +  ] | 
|  | 169 | +  external_address = openstack_networking_floatingip_v2.example.address | 
|  | 170 | +  options = { | 
|  | 171 | +    private_network_only = false | 
|  | 172 | +  } | 
|  | 173 | +} | 
|  | 174 | +``` | 
|  | 175 | + | 
|  | 176 | +<!-- schema generated by tfplugindocs --> | 
|  | 177 | +## Schema | 
|  | 178 | + | 
|  | 179 | +### Required | 
|  | 180 | + | 
|  | 181 | +- `listeners` (Attributes List) List of all listeners which will accept traffic. Limited to 20. (see [below for nested schema](#nestedatt--listeners)) | 
|  | 182 | +- `name` (String) Load balancer name. | 
|  | 183 | +- `networks` (Attributes List) List of networks that listeners and targets reside in. (see [below for nested schema](#nestedatt--networks)) | 
|  | 184 | +- `project_id` (String) STACKIT project ID to which the Load Balancer is associated. | 
|  | 185 | +- `target_pools` (Attributes List) List of all target pools which will be used in the Load Balancer. Limited to 20. (see [below for nested schema](#nestedatt--target_pools)) | 
|  | 186 | + | 
|  | 187 | +### Optional | 
|  | 188 | + | 
|  | 189 | +- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed. | 
|  | 190 | +- `options` (Attributes) Defines any optional functionality you want to have enabled on your load balancer. (see [below for nested schema](#nestedatt--options)) | 
|  | 191 | + | 
|  | 192 | +### Read-Only | 
|  | 193 | + | 
|  | 194 | +- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`name`". | 
|  | 195 | +- `private_address` (String) Transient private Load Balancer IP address. It can change any time. | 
|  | 196 | + | 
|  | 197 | +<a id="nestedatt--listeners"></a> | 
|  | 198 | +### Nested Schema for `listeners` | 
|  | 199 | + | 
|  | 200 | +Optional: | 
|  | 201 | + | 
|  | 202 | +- `display_name` (String) | 
|  | 203 | +- `port` (Number) Port number where we listen for traffic. | 
|  | 204 | +- `protocol` (String) Protocol is the highest network protocol we understand to load balance. | 
|  | 205 | +- `target_pool` (String) Reference target pool by target pool name. | 
|  | 206 | + | 
|  | 207 | + | 
|  | 208 | +<a id="nestedatt--networks"></a> | 
|  | 209 | +### Nested Schema for `networks` | 
|  | 210 | + | 
|  | 211 | +Required: | 
|  | 212 | + | 
|  | 213 | +- `network_id` (String) Openstack network ID. | 
|  | 214 | + | 
|  | 215 | +Optional: | 
|  | 216 | + | 
|  | 217 | +- `role` (String) The role defines how the load balancer is using the network. | 
|  | 218 | + | 
|  | 219 | + | 
|  | 220 | +<a id="nestedatt--target_pools"></a> | 
|  | 221 | +### Nested Schema for `target_pools` | 
|  | 222 | + | 
|  | 223 | +Required: | 
|  | 224 | + | 
|  | 225 | +- `name` (String) Target pool name. | 
|  | 226 | +- `target_port` (Number) Identical port number where each target listens for traffic. | 
|  | 227 | +- `targets` (Attributes List) List of all targets which will be used in the pool. Limited to 250. (see [below for nested schema](#nestedatt--target_pools--targets)) | 
|  | 228 | + | 
|  | 229 | +Optional: | 
|  | 230 | + | 
|  | 231 | +- `active_health_check` (Attributes) (see [below for nested schema](#nestedatt--target_pools--active_health_check)) | 
|  | 232 | + | 
|  | 233 | +<a id="nestedatt--target_pools--targets"></a> | 
|  | 234 | +### Nested Schema for `target_pools.targets` | 
|  | 235 | + | 
|  | 236 | +Required: | 
|  | 237 | + | 
|  | 238 | +- `display_name` (String) Target display name | 
|  | 239 | +- `ip` (String) Target IP | 
|  | 240 | + | 
|  | 241 | + | 
|  | 242 | +<a id="nestedatt--target_pools--active_health_check"></a> | 
|  | 243 | +### Nested Schema for `target_pools.active_health_check` | 
|  | 244 | + | 
|  | 245 | +Optional: | 
|  | 246 | + | 
|  | 247 | +- `healthy_threshold` (Number) Healthy threshold of the health checking. | 
|  | 248 | +- `interval` (String) Interval duration of health checking in seconds. | 
|  | 249 | +- `interval_jitter` (String) Interval duration threshold of the health checking in seconds. | 
|  | 250 | +- `timeout` (String) Active health checking timeout duration in seconds. | 
|  | 251 | +- `unhealthy_threshold` (Number) Unhealthy threshold of the health checking. | 
|  | 252 | + | 
|  | 253 | + | 
|  | 254 | + | 
|  | 255 | +<a id="nestedatt--options"></a> | 
|  | 256 | +### Nested Schema for `options` | 
|  | 257 | + | 
|  | 258 | +Optional: | 
|  | 259 | + | 
|  | 260 | +- `acl` (Set of String) Load Balancer is accessible only from an IP address in this range. | 
|  | 261 | +- `private_network_only` (Boolean) If true, Load Balancer is accessible only via a private network IP address. | 
0 commit comments