Skip to content

Commit 176fb84

Browse files
authored
feat: region adjustment for load balancer (#721)
* remove deprecated "credential" resource of loadbalancer * region adjustment load balancer - adapted load balancer example
1 parent 1444376 commit 176fb84

File tree

17 files changed

+250
-624
lines changed

17 files changed

+250
-624
lines changed

docs/data-sources/loadbalancer.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ data "stackit_loadbalancer" "example" {
2727
- `name` (String) Load balancer name.
2828
- `project_id` (String) STACKIT project ID to which the Load Balancer is associated.
2929

30+
### Optional
31+
32+
- `region` (String) The resource region. If not defined, the provider region is used.
33+
3034
### Read-Only
3135

3236
- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed.
33-
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`name`".
37+
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","region","`name`".
3438
- `listeners` (Attributes List) List of all listeners which will accept traffic. Limited to 20. (see [below for nested schema](#nestedatt--listeners))
3539
- `networks` (Attributes List) List of networks that listeners and targets reside in. (see [below for nested schema](#nestedatt--networks))
3640
- `options` (Attributes) Defines any optional functionality you want to have enabled on your load balancer. (see [below for nested schema](#nestedatt--options))

docs/resources/loadbalancer.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ resource "stackit_network_interface" "nic" {
3535
network_id = stackit_network.example_network.network_id
3636
}
3737
38-
# Create a public IP and assign it to the network interface
38+
# Create a public IP for the load balancer
3939
resource "stackit_public_ip" "public-ip" {
40-
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
41-
network_interface_id = stackit_network_interface.nic.network_interface_id
40+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
41+
lifecycle {
42+
ignore_changes = [network_interface_id]
43+
}
4244
}
4345
4446
# Create a key pair for accessing the server instance
@@ -48,7 +50,7 @@ resource "stackit_key_pair" "keypair" {
4850
}
4951
5052
# Create a server instance
51-
resource "stackit_server" "boot-from-volume" {
53+
resource "stackit_server" "boot-from-image" {
5254
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
5355
name = "example-server"
5456
boot_volume = {
@@ -64,7 +66,7 @@ resource "stackit_server" "boot-from-volume" {
6466
# Attach the network interface to the server
6567
resource "stackit_server_network_interface_attach" "nic-attachment" {
6668
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
67-
server_id = stackit_server.boot-from-volume.server_id
69+
server_id = stackit_server.boot-from-image.server_id
6870
network_interface_id = stackit_network_interface.nic.network_interface_id
6971
}
7072
@@ -78,7 +80,7 @@ resource "stackit_loadbalancer" "example" {
7880
target_port = 80
7981
targets = [
8082
{
81-
display_name = "example-target"
83+
display_name = stackit_server.boot-from-image.name
8284
ip = stackit_network_interface.nic.ipv4
8385
}
8486
]
@@ -127,10 +129,11 @@ resource "stackit_loadbalancer" "example" {
127129

128130
- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed.
129131
- `options` (Attributes) Defines any optional functionality you want to have enabled on your load balancer. (see [below for nested schema](#nestedatt--options))
132+
- `region` (String) The resource region. If not defined, the provider region is used.
130133

131134
### Read-Only
132135

133-
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`name`".
136+
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","region","`name`".
134137
- `private_address` (String) Transient private Load Balancer IP address. It can change any time.
135138

136139
<a id="nestedatt--listeners"></a>

docs/resources/loadbalancer_credential.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/resources/loadbalancer_observability_credential.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ resource "stackit_loadbalancer_observability_credential" "example" {
3131
- `project_id` (String) STACKIT project ID to which the load balancer observability credential is associated.
3232
- `username` (String) The password for the observability service (e.g. Argus) where the logs/metrics will be pushed into.
3333

34+
### Optional
35+
36+
- `region` (String) The resource region. If not defined, the provider region is used.
37+
3438
### Read-Only
3539

3640
- `credentials_ref` (String) The credentials reference is used by the Load Balancer to define which credentials it will use.
37-
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`credentials_ref`".
41+
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","region","`credentials_ref`".

examples/resources/stackit_loadbalancer/resource.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ resource "stackit_network_interface" "nic" {
1616
network_id = stackit_network.example_network.network_id
1717
}
1818

19-
# Create a public IP and assign it to the network interface
19+
# Create a public IP for the load balancer
2020
resource "stackit_public_ip" "public-ip" {
21-
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22-
network_interface_id = stackit_network_interface.nic.network_interface_id
21+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22+
lifecycle {
23+
ignore_changes = [network_interface_id]
24+
}
2325
}
2426

2527
# Create a key pair for accessing the server instance
@@ -29,7 +31,7 @@ resource "stackit_key_pair" "keypair" {
2931
}
3032

3133
# Create a server instance
32-
resource "stackit_server" "boot-from-volume" {
34+
resource "stackit_server" "boot-from-image" {
3335
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3436
name = "example-server"
3537
boot_volume = {
@@ -45,7 +47,7 @@ resource "stackit_server" "boot-from-volume" {
4547
# Attach the network interface to the server
4648
resource "stackit_server_network_interface_attach" "nic-attachment" {
4749
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
48-
server_id = stackit_server.boot-from-volume.server_id
50+
server_id = stackit_server.boot-from-image.server_id
4951
network_interface_id = stackit_network_interface.nic.network_interface_id
5052
}
5153

@@ -59,7 +61,7 @@ resource "stackit_loadbalancer" "example" {
5961
target_port = 80
6062
targets = [
6163
{
62-
display_name = "example-target"
64+
display_name = stackit_server.boot-from-image.name
6365
ip = stackit_network_interface.nic.ipv4
6466
}
6567
]

examples/resources/stackit_loadbalancer_credential/resource.tf

Lines changed: 0 additions & 6 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/stackitcloud/stackit-sdk-go/services/argus v0.11.0
1616
github.com/stackitcloud/stackit-sdk-go/services/dns v0.13.0
1717
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.21.1
18-
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.18.0
18+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.0.0
1919
github.com/stackitcloud/stackit-sdk-go/services/logme v0.21.0
2020
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.21.0
2121
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.18.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ github.com/stackitcloud/stackit-sdk-go/services/iaas v0.21.1 h1:ZFFJr54FcYTUBjE+
163163
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.21.1/go.mod h1:9p5IIdOKOM5/DIjbenKrWvz6GlSps4jsPJZkH7QJuRU=
164164
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.18.0 h1:7nNjIIcBQRDVnW4NL7+R8DaCKEqxxxsmVsgOVe50ZMU=
165165
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.18.0/go.mod h1:UFujBT+JlNvl6JNrY96UpLGqp+lZTD+JWL7siqhGPlw=
166+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.0.0 h1:z2p0OobEAgSE5bQr+KR+4Y1QTvDbSC2a7w2eCV/oSp4=
167+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.0.0/go.mod h1:x0jgrL+/K2cE4BvcIQByFUf0nOPVZRqq5Z074kjjr64=
166168
github.com/stackitcloud/stackit-sdk-go/services/logme v0.21.0 h1:P7bxaVzkZPGMWItLynKIvc88Xh6jCnK4dPTTT+L607o=
167169
github.com/stackitcloud/stackit-sdk-go/services/logme v0.21.0/go.mod h1:os4Kp2+jkMUJ2dZtgU9A91N3EJSw3MMh2slxgK1609g=
168170
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.21.0 h1:ks1i+cfD/YPRss//4aq6uvxbLvUwb5QvcUrOPeboLFY=

0 commit comments

Comments
 (0)