Skip to content

Commit 9d67362

Browse files
authored
Fix(lb): release_ip deprecated (#1020)
1 parent 5e2729f commit 9d67362

7 files changed

+1044
-1028
lines changed

docs/guides/migration_guide_v2.md

+34
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,37 @@ The `scaleway_bucket` was moved to the `object` product in the `storage` product
298298

299299
It's behaviour remained the same, but we also added an [`acl` attribute](../resources/object_bucket.md#acl).
300300
This attribute takes canned ACLs.
301+
302+
### LoadBalancer
303+
304+
#### Remove: `scaleway_lb.release_ip`
305+
306+
The attribute `scaleway_lb.release_ip` will be deprecated on the provider's next releases.
307+
308+
It's behaviour remain the same, but the IPs will be managed by the resource `scaleway_lb_ip`.
309+
This prevents the destruction of the IP from releasing the LBs resources.
310+
311+
v1.X
312+
313+
```shell
314+
resource scaleway_lb_ip ip01 {
315+
}
316+
resource scaleway_lb main {
317+
ip_id = scaleway_lb_ip.ip01.id
318+
name = "release-ip"
319+
type = "LB-S"
320+
release_ip = true
321+
}
322+
```
323+
324+
v2.X
325+
326+
```shell
327+
resource scaleway_lb_ip ip01 {
328+
}
329+
resource scaleway_lb main {
330+
ip_id = scaleway_lb_ip.ip01.id
331+
name = "release-ip"
332+
type = "LB-S"
333+
}
334+
```

docs/resources/lb.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "scaleway_lb" "base" {
2121
ip_id = scaleway_lb_ip.ip.id
2222
zone = "fr-par-1"
2323
type = "LB-S"
24-
release_ip = true
24+
release_ip = false
2525
}
2626
```
2727

@@ -55,6 +55,8 @@ In addition to all arguments above, the following attributes are exported:
5555
- `ip_address` - The load-balance public IP Address
5656
- `organization_id` - The organization ID the load-balancer is associated with.
5757

58+
~> **Important:** `release_ip` will not be supported. This prevents the destruction of the IP from releasing a LBs.
59+
The `resource_lb_ip` will be the only resource that handles those IPs.
5860
## IP ID
5961

6062
Since v1.15.0, `ip_id` is a required field. This means that now a separate `scaleway_lb_ip` is required.
@@ -80,7 +82,7 @@ resource "scaleway_lb" "base" {
8082
ip_id = scaleway_lb_ip.ip.id
8183
zone = "fr-par-1"
8284
type = "LB-S"
83-
release_ip = true
85+
release_ip = false
8486
}
8587
```
8688

scaleway/data_source_lb.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,7 @@ func dataSourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta
6363
lbID = res.LBs[0].ID
6464
}
6565

66-
var relaseIPValue bool
67-
releaseIPAddress, releaseIPExist := d.GetOk("release_ip")
68-
if releaseIPExist {
69-
relaseIPValue = *expandBoolPtr(releaseIPAddress)
70-
}
71-
72-
err = d.Set("release_ip", relaseIPValue)
66+
err = d.Set("release_ip", false)
7367
if err != nil {
7468
return diag.FromErr(err)
7569
}

scaleway/resource_lb.go

+3-14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func resourceScalewayLb() *schema.Resource {
7171
Optional: true,
7272
Default: false,
7373
Description: "Release the IPs related to this load-balancer",
74+
Deprecated: "The resource ip will be destroyed by it's own resource. Please set this to `false`",
7475
},
7576
"private_network": {
7677
Type: schema.TypeList,
@@ -211,13 +212,7 @@ func resourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta in
211212
return diag.FromErr(err)
212213
}
213214

214-
var relaseIPValue bool
215-
releaseIPAddress, releaseIPPExist := d.GetOk("release_ip")
216-
if releaseIPPExist {
217-
relaseIPValue = *expandBoolPtr(releaseIPAddress)
218-
}
219-
220-
_ = d.Set("release_ip", relaseIPValue)
215+
_ = d.Set("release_ip", false)
221216
_ = d.Set("name", res.Name)
222217
_ = d.Set("zone", zone.String())
223218
_ = d.Set("region", region.String())
@@ -403,16 +398,10 @@ func resourceScalewayLbDelete(ctx context.Context, d *schema.ResourceData, meta
403398
}
404399
}
405400

406-
var releaseAddressValue bool
407-
releaseIPAddress, releaseIPPExist := d.GetOk("release_ip")
408-
if releaseIPPExist {
409-
releaseAddressValue = *expandBoolPtr(releaseIPAddress)
410-
}
411-
412401
err = lbAPI.DeleteLB(&lb.ZonedAPIDeleteLBRequest{
413402
Zone: zone,
414403
LBID: ID,
415-
ReleaseIP: releaseAddressValue,
404+
ReleaseIP: false,
416405
}, scw.WithContext(ctx))
417406
if err != nil && !is404Error(err) {
418407
return diag.FromErr(err)

scaleway/resource_lb_ip_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func TestAccScalewayLbIP_Basic(t *testing.T) {
8585
ip_id = scaleway_lb_ip.ip01.id
8686
name = "test-lb-with-release-ip"
8787
type = "LB-S"
88-
release_ip = true
8988
}
9089
`,
9190
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)