Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(lb): release_ip deprecated #1020

Merged
merged 7 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/guides/migration_guide_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,37 @@ The `scaleway_bucket` was moved to the `object` product in the `storage` product

It's behaviour remained the same, but we also added an [`acl` attribute](../resources/object_bucket.md#acl).
This attribute takes canned ACLs.

### LoadBalancer

#### Remove: `scaleway_lb.release_ip`

The attribute `scaleway_lb.release_ip` will be deprecated on the provider's next releases.

It's behaviour remain the same, but the IPs will be managed by the resource `scaleway_lb_ip`.
This prevents the destruction of the IP from releasing the LBs resources.

v1.X

```shell
resource scaleway_lb_ip ip01 {
}
resource scaleway_lb main {
ip_id = scaleway_lb_ip.ip01.id
name = "release-ip"
type = "LB-S"
release_ip = true
}
```

v2.X

```shell
resource scaleway_lb_ip ip01 {
}
resource scaleway_lb main {
ip_id = scaleway_lb_ip.ip01.id
name = "release-ip"
type = "LB-S"
}
```
6 changes: 4 additions & 2 deletions docs/resources/lb.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "scaleway_lb" "base" {
ip_id = scaleway_lb_ip.ip.id
zone = "fr-par-1"
type = "LB-S"
release_ip = true
release_ip = false
}
```

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

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

Since v1.15.0, `ip_id` is a required field. This means that now a separate `scaleway_lb_ip` is required.
Expand All @@ -80,7 +82,7 @@ resource "scaleway_lb" "base" {
ip_id = scaleway_lb_ip.ip.id
zone = "fr-par-1"
type = "LB-S"
release_ip = true
release_ip = false
}
```

Expand Down
8 changes: 1 addition & 7 deletions scaleway/data_source_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ func dataSourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta
lbID = res.LBs[0].ID
}

var relaseIPValue bool
releaseIPAddress, releaseIPExist := d.GetOk("release_ip")
if releaseIPExist {
relaseIPValue = *expandBoolPtr(releaseIPAddress)
}

err = d.Set("release_ip", relaseIPValue)
err = d.Set("release_ip", false)
if err != nil {
return diag.FromErr(err)
}
Expand Down
17 changes: 3 additions & 14 deletions scaleway/resource_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func resourceScalewayLb() *schema.Resource {
Optional: true,
Default: false,
Description: "Release the IPs related to this load-balancer",
Deprecated: "The resource ip will be destroyed by it's own resource. Please set this to `false`",
},
"private_network": {
Type: schema.TypeList,
Expand Down Expand Up @@ -211,13 +212,7 @@ func resourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta in
return diag.FromErr(err)
}

var relaseIPValue bool
releaseIPAddress, releaseIPPExist := d.GetOk("release_ip")
if releaseIPPExist {
relaseIPValue = *expandBoolPtr(releaseIPAddress)
}

_ = d.Set("release_ip", relaseIPValue)
_ = d.Set("release_ip", false)
_ = d.Set("name", res.Name)
_ = d.Set("zone", zone.String())
_ = d.Set("region", region.String())
Expand Down Expand Up @@ -403,16 +398,10 @@ func resourceScalewayLbDelete(ctx context.Context, d *schema.ResourceData, meta
}
}

var releaseAddressValue bool
releaseIPAddress, releaseIPPExist := d.GetOk("release_ip")
if releaseIPPExist {
releaseAddressValue = *expandBoolPtr(releaseIPAddress)
}

err = lbAPI.DeleteLB(&lb.ZonedAPIDeleteLBRequest{
Zone: zone,
LBID: ID,
ReleaseIP: releaseAddressValue,
ReleaseIP: false,
}, scw.WithContext(ctx))
if err != nil && !is404Error(err) {
return diag.FromErr(err)
Expand Down
1 change: 0 additions & 1 deletion scaleway/resource_lb_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestAccScalewayLbIP_Basic(t *testing.T) {
ip_id = scaleway_lb_ip.ip01.id
name = "test-lb-with-release-ip"
type = "LB-S"
release_ip = true
}
`,
Check: resource.ComposeTestCheckFunc(
Expand Down
Loading