Skip to content

Commit 14ad34d

Browse files
committed
add guide + update documentation and templates
1 parent f2c4381 commit 14ad34d

File tree

12 files changed

+306
-58
lines changed

12 files changed

+306
-58
lines changed

docs/data-sources/instance_server.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ You find all the available types on the [pricing page](https://www.scaleway.com/
5959
- `additional_volume_ids` - The [additional volumes](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39)
6060
attached to the server.
6161

62-
- `enable_ipv6` - Determines if IPv6 is enabled for the server.
63-
6462
- `enable_dynamic_ip` - True if dynamic IP in enable on the server.
6563

6664
- `state` - The state of the server. Possible values are: `started`, `stopped` or `standby`.
@@ -78,16 +76,10 @@ attached to the server.
7876
- `root_volume`
7977
- `volume_id` - The volume ID of the root volume of the server.
8078

81-
- `private_ip` - The Scaleway internal IP address of the server.
82-
83-
- `public_ip` - The public IP address of the server.
84-
8579
- `public_ips` - The list of public IPs of the server
8680
- `id` - The ID of the IP
8781
- `address` - The address of the IP
8882

89-
- `ipv6_address` - The default ipv6 address routed to the server. ( Only set when enable_ipv6 is set to true )
90-
91-
- `ipv6_gateway` - The ipv6 gateway address. ( Only set when enable_ipv6 is set to true )
92-
93-
- `ipv6_prefix_length` - The prefix length of the ipv6 subnet routed to the server. ( Only set when enable_ipv6 is set to true )
83+
- `private_ips` - The list of private IPs of the server.
84+
- `id` - The ID of the IP address resource.
85+
- `address` - The private IP address.

docs/data-sources/instance_servers.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ In addition to all above arguments, the following attributes are exported:
4444
~> **Important:** Instance servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
4545

4646
- `tags` - The tags associated with the server.
47-
- `public_ip` - The public IP address of the server.
48-
- `private_ip` - The Scaleway internal IP address of the server.
4947
- `private_ips` - The list of private IPv4 and IPv6 addresses associated with the server.
5048
- `id` - The ID of the IP address resource.
5149
- `address` - The private IP address.
@@ -59,14 +57,8 @@ In addition to all above arguments, the following attributes are exported:
5957
- `boot_type` - The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`.
6058
- `type` - The commercial type of the server.
6159
- `security_group_id` - The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to.
62-
- `enable_ipv6` - Determines if IPv6 is enabled for the server.
63-
- `ipv6_address` - The default ipv6 address routed to the server. ( Only set when enable_ipv6 is set to true )
64-
- `ipv6_gateway` - The ipv6 gateway address. ( Only set when enable_ipv6 is set to true )
65-
- `ipv6_prefix_length` - The prefix length of the ipv6 subnet routed to the server. ( Only set when enable_ipv6 is set to true )
6660
- `enable_dynamic_ip` - If true a dynamic IP will be attached to the server.
6761
- `image` - The UUID or the label of the base image used by the server.
6862
- `placement_group_id` - The [placement group](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) the server is attached to.
6963
- `organization_id` - The organization ID the server is associated with.
7064
- `project_id` - The ID of the project the server is associated with.
71-
72-
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
page_title: "Instance Server IP Fields Deprecation Guide"
3+
---
4+
5+
# How to modify your Terraform configuration to use the Instance Server IP lists fields
6+
7+
## Instance server `public_ip` and `private_ip` fields replacement
8+
9+
The `public_ip` and `private_ip` computed fields of the `scaleway_instance_server` resource were deprecated since `v2.44.0`
10+
of the provider (`v2.49.0` for `private_ip`) in favor of the `public_ips` and `private_ips` list attributes.
11+
They will be removed in the `v2.61.0` release.
12+
13+
This may be a breaking change for you if you are using those fields in your Terraform configuration, either for output
14+
purposes or in the definition of another resource, for example a load-balancer or an ACL resource.
15+
16+
In this guide, we will take the example of a load-balancer backend resource.
17+
18+
### Single public IP
19+
20+
```hcl
21+
resource "scaleway_instance_ip" "ip_v4" {
22+
type = "routed_ipv4"
23+
}
24+
resource "scaleway_instance_server" "server" {
25+
image = "ubuntu_noble"
26+
type = "PRO2-S"
27+
ip_id = scaleway_instance_ip.ip_v4.id
28+
}
29+
resource "scaleway_lb" "lb" {
30+
type = "LB-S"
31+
}
32+
resource "scaleway_lb_backend" "backend" {
33+
lb_id = scaleway_lb.lb.id
34+
forward_port = 80
35+
forward_protocol = "http"
36+
37+
# Before
38+
server_ips = [ scaleway_instance_server.server.public_ip ]
39+
# Now
40+
server_ips = [ scaleway_instance_server.server.public_ips.0.address ]
41+
}
42+
```
43+
44+
### Multiple public IPs, but only select the IPv4 addresses
45+
46+
This was not achievable with the singular `public_ip` field, but here is how to do it with the `public_ips` field.
47+
48+
**NB**: For private IPs, the logic is the same, just replace `public_ips` by `private_ips`. (Note that the declarations
49+
of private IPs are not shown here)
50+
51+
**NB**: For IPv6 addresses, the logic is the same, just replace `inet` by `inet6`.
52+
53+
```hcl
54+
# Declare 3 public IPv4 addresses
55+
resource "scaleway_instance_ip" "ip_v4" {
56+
type = "routed_ipv4"
57+
count = 3
58+
}
59+
# Declare 3 public IPv6 addresses
60+
resource "scaleway_instance_ip" "ip_v6" {
61+
type = "routed_ipv6"
62+
count = 3
63+
}
64+
# Declare a server with all IPs attached
65+
resource "scaleway_instance_server" "server" {
66+
image = "ubuntu_noble"
67+
type = "PRO2-S"
68+
ip_ids = concat(
69+
[ for ip in scaleway_instance_ip.ip_v4 : ip.id ],
70+
[ for ip in scaleway_instance_ip.ip_v6 : ip.id ],
71+
)
72+
}
73+
# Declare a load-balancer
74+
resource "scaleway_lb" "lb" {
75+
type = "LB-S"
76+
}
77+
# Declare a backend with only the IPv4 addresses
78+
resource "scaleway_lb_backend" "backend" {
79+
lb_id = scaleway_lb.lb.id
80+
forward_port = 80
81+
forward_protocol = "http"
82+
83+
server_ips = [
84+
for ip in scaleway_instance_server.server.public_ips : ip.address
85+
if ip.family == "inet"
86+
]
87+
}
88+
```
89+
90+
### Private IP
91+
92+
```hcl
93+
# Declare a VPC and a private network
94+
resource "scaleway_vpc" "vpc" {}
95+
resource "scaleway_vpc_private_network" "pn" {
96+
vpc_id = scaleway_vpc.vpc.id
97+
}
98+
# Declare a server attached to the private network, this will create a private IPv4 and IPv6
99+
resource "scaleway_instance_server" "server" {
100+
image = "ubuntu_noble"
101+
type = "PRO2-S"
102+
private_network {
103+
pn_id = scaleway_vpc_private_network.pn.id
104+
}
105+
}
106+
# Declare a load-balancer
107+
resource "scaleway_lb" "lb" {
108+
type = "LB-S"
109+
}
110+
# Declare a backend with the private IPs
111+
resource "scaleway_lb_backend" "backend" {
112+
lb_id = scaleway_lb.lb.id
113+
forward_port = 80
114+
forward_protocol = "http"
115+
116+
# Before (the private_ip field was set to the IPv4)
117+
server_ips = [ scaleway_instance_server.server.private_ip ]
118+
# Now: set the IPv4 (index 1 in the list)
119+
server_ips = [ scaleway_instance_server.server.private_ips.1.address ]
120+
# Or set both the IPv4 and IPv6
121+
server_ips = [
122+
scaleway_instance_server.server.private_ips.0.address,
123+
scaleway_instance_server.server.private_ips.1.address,
124+
]
125+
}
126+
```
127+
128+
## Instance server IPv6 fields removal
129+
130+
The fields concerning IPv6 were removed from the `scaleway_instance_server` resource as the information they provided was
131+
no longer accurate.
132+
133+
These fields were:
134+
135+
- `enable_ipv6`, which was false in the state, but is now true for all servers.
136+
- `ipv6_address`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.address` whether
137+
the IP is public or private.
138+
- `ipv6_gateway`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.gateway` whether
139+
the IP is public or private.
140+
- `ipv6_prefix_length`, which was 0 in the state.

docs/guides/migration_guide_v2.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ $ terraform state show scaleway_server.main
127127
# scaleway_server.main:
128128
resource "scaleway_server" "main" {
129129
boot_type = "local"
130-
enable_ipv6 = false
131130
id = "11111111-1111-1111-1111-111111111111"
132131
image = "cf44b8f5-77e2-42ed-8f1e-09ed5bb028fc"
133132
name = "foobar"

docs/resources/instance_server.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,9 @@ In addition to all arguments above, the following attributes are exported:
286286

287287
~> **Important:** Instance servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
288288

289-
- `placement_group_policy_respected` - (Deprecated) Always false, use [instance_placement_group ressource](instance_placement_group.md) to known when the placement group policy is respected.
289+
- `placement_group_policy_respected` - (Deprecated) Always false, use [instance_placement_group resource](instance_placement_group.md) to known when the placement group policy is respected.
290290
- `root_volume`
291291
- `volume_id` - The volume ID of the root volume of the server.
292-
- `private_ip` - The Scaleway internal IP address of the server (Deprecated use [ipam_ip datasource](../data-sources/ipam_ip.md#instance-private-network-ip) instead).
293-
- `public_ip` - The public IP address of the server (Deprecated use `public_ips` instead).
294292
- `public_ips` - The list of public IPs of the server.
295293
- `id` - The ID of the IP.
296294
- `address` - The address of the IP.
@@ -299,6 +297,9 @@ In addition to all arguments above, the following attributes are exported:
299297
- `family` - The IP address' family.
300298
- `dynamic` - Whether the IP is dynamic.
301299
- `provisioning_mode` - The provisioning mode of the IP
300+
- `private_ips` - The list of private IPs of the server.
301+
- `id` - The ID of the IP.
302+
- `address` - The address of the IP.
302303
- `boot_type` - The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`.
303304
- `organization_id` - The organization ID the server is associated with.
304305

internal/services/instance/server.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func ResourceServer() *schema.Resource {
7474
"type": {
7575
Type: schema.TypeString,
7676
Required: true,
77-
Description: "The instanceSDK type of the server", // TODO: link to scaleway pricing in the doc
77+
Description: "The instance type of the server", // TODO: link to scaleway pricing in the doc
7878
DiffSuppressFunc: dsf.IgnoreCase,
7979
},
8080
"protected": {
@@ -158,7 +158,7 @@ func ResourceServer() *schema.Resource {
158158
Type: schema.TypeBool,
159159
Optional: true,
160160
Default: true,
161-
Description: "Force deletion of the root volume on instanceSDK termination",
161+
Description: "Force deletion of the root volume on instance termination",
162162
},
163163
"boot": {
164164
Type: schema.TypeBool,
@@ -265,7 +265,7 @@ func ResourceServer() *schema.Resource {
265265
Type: schema.TypeList,
266266
Optional: true,
267267
MaxItems: 8,
268-
Description: "List of private network to connect with your instanceSDK",
268+
Description: "List of private network to connect with your instance",
269269
Elem: &schema.Resource{
270270
Timeouts: &schema.ResourceTimeout{
271271
Default: schema.DefaultTimeout(defaultInstancePrivateNICWaitTimeout),
@@ -302,7 +302,7 @@ func ResourceServer() *schema.Resource {
302302
Type: schema.TypeList,
303303
Optional: true,
304304
Computed: true,
305-
Description: "List of public IPs attached to your instanceSDK",
305+
Description: "List of private IPv4 and IPv6 addresses attached to your instance",
306306
Elem: &schema.Resource{
307307
Schema: map[string]*schema.Schema{
308308
"id": {
@@ -347,18 +347,18 @@ func ResourceServer() *schema.Resource {
347347
Type: schema.TypeList,
348348
Computed: true,
349349
Optional: true,
350-
Description: "List of private IPv4 addresses associated with the resource",
350+
Description: "List of private IPv4 and IPv6 addresses associated with the resource",
351351
Elem: &schema.Resource{
352352
Schema: map[string]*schema.Schema{
353353
"id": {
354354
Type: schema.TypeString,
355355
Computed: true,
356-
Description: "The ID of the IPv4 address resource",
356+
Description: "The ID of the IP address resource",
357357
},
358358
"address": {
359359
Type: schema.TypeString,
360360
Computed: true,
361-
Description: "The private IPv4 address",
361+
Description: "The private IP address",
362362
},
363363
},
364364
},
@@ -930,7 +930,7 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
930930
updateRequest.PlacementGroup = &instanceSDK.NullableStringValue{Null: true}
931931
} else {
932932
if !isStopped {
933-
return diag.FromErr(errors.New("instanceSDK must be stopped to change placement group"))
933+
return diag.FromErr(errors.New("instance must be stopped to change placement group"))
934934
}
935935

936936
updateRequest.PlacementGroup = &instanceSDK.NullableStringValue{Value: placementGroupID}
@@ -974,7 +974,7 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
974974
if !isStopped {
975975
warnings = append(warnings, diag.Diagnostic{
976976
Severity: diag.Warning,
977-
Summary: "instanceSDK may need to be rebooted to use the new boot type",
977+
Summary: "instance may need to be rebooted to use the new boot type",
978978
})
979979
}
980980
}
@@ -998,7 +998,7 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
998998
if !isStopped && d.HasChange("user_data.cloud-init") {
999999
warnings = append(warnings, diag.Diagnostic{
10001000
Severity: diag.Warning,
1001-
Summary: "instanceSDK may need to be rebooted to use the new cloud init config",
1001+
Summary: "instance may need to be rebooted to use the new cloud init config",
10021002
})
10031003
}
10041004
}
@@ -1132,7 +1132,7 @@ func ResourceInstanceServerDelete(ctx context.Context, d *schema.ResourceData, m
11321132
ServerID: id,
11331133
}, scw.WithContext(ctx))
11341134
if err != nil {
1135-
log.Print("[WARN] Failed remove server from instanceSDK group")
1135+
log.Print("[WARN] Failed remove server from instance group")
11361136
}
11371137
}
11381138

internal/services/instance/testfuncs/sweep.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func testSweepServer(_ string) error {
102102
return acctest.SweepZones(scw.AllZones, func(scwClient *scw.Client, zone scw.Zone) error {
103103
instanceAPI := instanceSDK.NewAPI(scwClient)
104104

105-
logging.L.Debugf("sweeper: destroying the instanceSDK server in (%s)", zone)
105+
logging.L.Debugf("sweeper: destroying the instance server in (%s)", zone)
106106

107107
listServers, err := instanceAPI.ListServers(&instanceSDK.ListServersRequest{Zone: zone}, scw.WithAllPages())
108108
if err != nil {

templates/data-sources/instance_server.md.tmpl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ You find all the available types on the [pricing page](https://www.scaleway.com/
5959
- `additional_volume_ids` - The [additional volumes](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39)
6060
attached to the server.
6161

62-
- `enable_ipv6` - Determines if IPv6 is enabled for the server.
63-
6462
- `enable_dynamic_ip` - True if dynamic IP in enable on the server.
6563

6664
- `state` - The state of the server. Possible values are: `started`, `stopped` or `standby`.
@@ -78,16 +76,10 @@ attached to the server.
7876
- `root_volume`
7977
- `volume_id` - The volume ID of the root volume of the server.
8078

81-
- `private_ip` - The Scaleway internal IP address of the server.
82-
83-
- `public_ip` - The public IP address of the server.
84-
8579
- `public_ips` - The list of public IPs of the server
8680
- `id` - The ID of the IP
8781
- `address` - The address of the IP
8882

89-
- `ipv6_address` - The default ipv6 address routed to the server. ( Only set when enable_ipv6 is set to true )
90-
91-
- `ipv6_gateway` - The ipv6 gateway address. ( Only set when enable_ipv6 is set to true )
92-
93-
- `ipv6_prefix_length` - The prefix length of the ipv6 subnet routed to the server. ( Only set when enable_ipv6 is set to true )
83+
- `private_ips` - The list of private IPs of the server.
84+
- `id` - The ID of the IP address resource.
85+
- `address` - The private IP address.

templates/data-sources/instance_servers.md.tmpl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ In addition to all above arguments, the following attributes are exported:
4444
~> **Important:** Instance servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
4545

4646
- `tags` - The tags associated with the server.
47-
- `public_ip` - The public IP address of the server.
48-
- `private_ip` - The Scaleway internal IP address of the server.
4947
- `private_ips` - The list of private IPv4 and IPv6 addresses associated with the server.
5048
- `id` - The ID of the IP address resource.
5149
- `address` - The private IP address.
@@ -59,14 +57,8 @@ In addition to all above arguments, the following attributes are exported:
5957
- `boot_type` - The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`.
6058
- `type` - The commercial type of the server.
6159
- `security_group_id` - The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to.
62-
- `enable_ipv6` - Determines if IPv6 is enabled for the server.
63-
- `ipv6_address` - The default ipv6 address routed to the server. ( Only set when enable_ipv6 is set to true )
64-
- `ipv6_gateway` - The ipv6 gateway address. ( Only set when enable_ipv6 is set to true )
65-
- `ipv6_prefix_length` - The prefix length of the ipv6 subnet routed to the server. ( Only set when enable_ipv6 is set to true )
6660
- `enable_dynamic_ip` - If true a dynamic IP will be attached to the server.
6761
- `image` - The UUID or the label of the base image used by the server.
6862
- `placement_group_id` - The [placement group](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) the server is attached to.
6963
- `organization_id` - The organization ID the server is associated with.
7064
- `project_id` - The ID of the project the server is associated with.
71-
72-

0 commit comments

Comments
 (0)