Skip to content

Commit 5f8988d

Browse files
authored
fix(lb): type is now case insensitive to avoid force-recreate (#515)
1 parent 7c207ad commit 5f8988d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

scaleway/resource_lb_beta.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package scaleway
22

33
import (
4+
"strings"
5+
46
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
57
lb "github.com/scaleway/scaleway-sdk-go/api/lb/v1"
68
"github.com/scaleway/scaleway-sdk-go/scw"
@@ -24,10 +26,11 @@ func resourceScalewayLbBeta() *schema.Resource {
2426
Description: "Name of the lb",
2527
},
2628
"type": {
27-
Type: schema.TypeString,
28-
Required: true,
29-
ForceNew: true,
30-
Description: "The type of load-balancer you want to create",
29+
Type: schema.TypeString,
30+
Required: true,
31+
ForceNew: true,
32+
DiffSuppressFunc: diffSuppressFuncIgnoreCase,
33+
Description: "The type of load-balancer you want to create",
3134
},
3235
"tags": {
3336
Type: schema.TypeList,
@@ -116,7 +119,8 @@ func resourceScalewayLbBetaRead(d *schema.ResourceData, m interface{}) error {
116119
_ = d.Set("region", string(region))
117120
_ = d.Set("organization_id", res.OrganizationID)
118121
_ = d.Set("tags", res.Tags)
119-
_ = d.Set("type", res.Type)
122+
// For now API return lowercase lb type. This should be fix in a near future on the API side
123+
_ = d.Set("type", strings.ToUpper(res.Type))
120124
_ = d.Set("ip_id", newRegionalId(region, res.IP[0].ID))
121125
_ = d.Set("ip_address", res.IP[0].IPAddress)
122126

scaleway/resource_lb_beta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestAccScalewayLbAndIPBeta(t *testing.T) {
5757
resource scaleway_lb_beta lb01 {
5858
ip_id = scaleway_lb_ip_beta.ip01.id
5959
name = "test-lb"
60-
type = "lb-s"
60+
type = "LB-S"
6161
}
6262
`,
6363
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)