Skip to content

Commit a940fcc

Browse files
Marcel JacekMarcel Jacek
authored andcommitted
fix: set external_address for lb to optional
1 parent a2cd8a0 commit a940fcc

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

docs/resources/loadbalancer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ resource "stackit_loadbalancer" "example" {
119119

120120
### Required
121121

122-
- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed.
123122
- `listeners` (Attributes List) List of all listeners which will accept traffic. Limited to 20. (see [below for nested schema](#nestedatt--listeners))
124123
- `name` (String) Load balancer name.
125124
- `networks` (Attributes List) List of networks that listeners and targets reside in. (see [below for nested schema](#nestedatt--networks))
@@ -128,6 +127,7 @@ resource "stackit_loadbalancer" "example" {
128127

129128
### Optional
130129

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

stackit/internal/services/loadbalancer/loadbalancer/resource.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
1011
loadbalancerUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/loadbalancer/utils"
1112

1213
"github.com/google/uuid"
@@ -237,6 +238,16 @@ func (r *loadBalancerResource) ModifyPlan(ctx context.Context, req resource.Modi
237238
}
238239
}
239240

241+
// ConfigValidators validates the resource configuration
242+
func (r *loadBalancerResource) ConfigValidators(_ context.Context) []resource.ConfigValidator {
243+
return []resource.ConfigValidator{
244+
resourcevalidator.AtLeastOneOf(
245+
path.MatchRoot("external_address"),
246+
path.MatchRoot("options").AtName("private_network_only"),
247+
),
248+
}
249+
}
250+
240251
// Configure adds the provider configured client to the resource.
241252
func (r *loadBalancerResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
242253
var ok bool
@@ -327,7 +338,7 @@ The example below creates the supporting infrastructure using the STACKIT Terraf
327338
},
328339
"external_address": schema.StringAttribute{
329340
Description: descriptions["external_address"],
330-
Required: true,
341+
Optional: true,
331342
PlanModifiers: []planmodifier.String{
332343
stringplanmodifier.RequiresReplace(),
333344
},

0 commit comments

Comments
 (0)