Skip to content

Commit aa3bd70

Browse files
committed
doc: add guide
1 parent 1bc44e1 commit aa3bd70

File tree

2 files changed

+278
-0
lines changed

2 files changed

+278
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
- `enable_ipv6`, which was false in the state, but is now true for all servers.
135+
- `ipv6_address`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.address` whether
136+
the IP is public or private.
137+
- `ipv6_gateway`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.gateway` whether
138+
the IP is public or private.
139+
- `ipv6_prefix_length`, which was 0 in the state.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
- `enable_ipv6`, which was false in the state, but is now true for all servers.
135+
- `ipv6_address`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.address` whether
136+
the IP is public or private.
137+
- `ipv6_gateway`, which was null in the state, but can now be retrieved in the `[public|private]_ips.X.gateway` whether
138+
the IP is public or private.
139+
- `ipv6_prefix_length`, which was 0 in the state.

0 commit comments

Comments
 (0)