Skip to content

Commit ba041f4

Browse files
yfodilRoRoJremyleone
authored
docs(vpcgw): add v2 migration guide (#2991)
* docs(vpcgw): add v2 migration guide * fix lint * fix lint * tabs * add title * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * fixes * lint * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rémy Léone <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rémy Léone <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rémy Léone <[email protected]> * Update docs/guides/migration_guide_vpcgw_v2.md Co-authored-by: Rowena Jones <[email protected]> * add cli command --------- Co-authored-by: Rowena Jones <[email protected]> Co-authored-by: Rémy Léone <[email protected]>
1 parent eaa7027 commit ba041f4

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
page_title: "Moving a Public Gateway from Legacy mode to IPAM mode, for v2 compatibility"
3+
---
4+
5+
# Moving a Public Gateway from Legacy mode to IPAM mode
6+
7+
This guide explains how to move a Public Gateway from [Legacy mode](https://www.scaleway.com/en/docs/public-gateways/concepts/#ipam) to IPAM mode. Only gateways in IPAM mode will be compatible with the new v2 of the Public Gateways API. v1 of the API is deprecated, and will be removed before the end of 2025.
8+
In the legacy setup, DHCP and DHCP reservations are managed with dedicated resources and referenced in the gateway network.
9+
In IPAM mode, these functionalities are managed by Scaleway IPAM.
10+
In 2023, DHCP functionality was moved from Public Gateways to Private Networks, DHCP resources are now no longer needed on the Public Gateway itself.
11+
12+
You can find out more about the deprecation of v1 of the Public Gateways API, and the obligatory move to IPAM mode, in the [main Public Gateways documentation](https://www.scaleway.com/en/docs/public-gateways/).
13+
14+
Note:
15+
Trigger the move from Legacy mode to IPAM mode by setting the `move_to_ipam` flag on your Public Gateway resource.
16+
You can do this via the Terraform configuration or by using the Scaleway CLI/Console.
17+
18+
Using the CLI:
19+
Ensure you have at least version v2.38.0 of the Scaleway CLI installed. Then run:
20+
21+
```bash
22+
scw vpc-gw gateway move-to-ipam 'id-of-the-public-gateway'
23+
```
24+
25+
26+
## Prerequisites
27+
28+
### Ensure the Latest Provider Version
29+
30+
Ensure your Scaleway Terraform provider is updated to at least version `2.52.0`.
31+
32+
```hcl
33+
terraform {
34+
required_providers {
35+
scaleway = {
36+
source = "scaleway/scaleway"
37+
version = "~> v2.52.0"
38+
}
39+
}
40+
}
41+
```
42+
43+
## Steps to Move to IPAM Mode
44+
45+
### Legacy Configuration
46+
47+
A typical legacy configuration might look like this:
48+
49+
```hcl
50+
resource "scaleway_vpc" "main" {
51+
name = "foo"
52+
}
53+
54+
resource "scaleway_vpc_private_network" "main" {
55+
name = "bar"
56+
vpc_id = scaleway_vpc.main.id
57+
}
58+
59+
resource "scaleway_vpc_public_gateway_ip" "main" {
60+
}
61+
62+
resource "scaleway_vpc_public_gateway" "main" {
63+
name = "foobar"
64+
type = "VPC-GW-S"
65+
ip_id = scaleway_vpc_public_gateway_ip.main.id
66+
}
67+
68+
resource "scaleway_vpc_public_gateway_dhcp" "main" {
69+
subnet = "192.168.1.0/24"
70+
}
71+
72+
resource "scaleway_instance_server" "main" {
73+
image = "ubuntu_focal"
74+
type = "DEV1-S"
75+
}
76+
77+
resource "scaleway_instance_private_nic" "main" {
78+
server_id = scaleway_instance_server.main.id
79+
private_network_id = scaleway_vpc_private_network.main.id
80+
}
81+
82+
resource "scaleway_vpc_gateway_network" "main" {
83+
gateway_id = scaleway_vpc_public_gateway.main.id
84+
private_network_id = scaleway_vpc_private_network.main.id
85+
dhcp_id = scaleway_vpc_public_gateway_dhcp.main.id
86+
cleanup_dhcp = true
87+
enable_masquerade = true
88+
}
89+
90+
resource "scaleway_vpc_public_gateway_dhcp_reservation" "main" {
91+
gateway_network_id = scaleway_vpc_gateway_network.main.id
92+
mac_address = scaleway_instance_private_nic.main.mac_address
93+
ip_address = "192.168.1.1"
94+
}
95+
```
96+
97+
### Triggering the move to IPAM-mode
98+
99+
Before updating your configuration, you must trigger the move to IPAM-mode on the Public Gateway resource. For example, add the `move_to_ipam` flag:
100+
101+
```hcl
102+
resource "scaleway_vpc_public_gateway" "main" {
103+
name = "foobar"
104+
type = "VPC-GW-S"
105+
ip_id = scaleway_vpc_public_gateway_ip.main.id
106+
move_to_ipam = true
107+
}
108+
```
109+
110+
This call puts the gateway into IPAM mode and means it will now be managed by v2 of the API instead of v1. The DHCP configuration and reservations remain intact, but the underlying resource is now managed using v2.
111+
112+
### Updated Configuration
113+
114+
After triggering the move, update your Terraform configuration as follows:
115+
116+
1. **Remove the DHCP and DHCP Reservation Resources**
117+
118+
Since DHCP functionality is built directly into Private Networks, you no longer need the DHCP configuration resources. Delete the following from your config:
119+
120+
`scaleway_vpc_public_gateway_dhcp`
121+
`scaleway_vpc_public_gateway_dhcp_reservation`
122+
123+
2. **Update the Gateway Network**
124+
125+
Replace the DHCP related attributes with an `ipam_config` block. For example
126+
127+
```hcl
128+
resource "scaleway_vpc_gateway_network" "main" {
129+
gateway_id = scaleway_vpc_public_gateway.main.id
130+
private_network_id = scaleway_vpc_private_network.main.id
131+
enable_masquerade = true
132+
ipam_config {
133+
push_default_route = false
134+
}
135+
}
136+
```
137+
138+
### Using the IPAM Datasource and Resource for Reservations
139+
140+
After putting your Public Gateway in IPAM mode, you no longer manage DHCP reservations with dedicated resources.
141+
Instead, you remove the legacy DHCP reservation resource and switch to using IPAM to manage your IPs.
142+
143+
1. **Retrieve an Existing IP with the IPAM Datasource**
144+
If you have already reserved an IP (for example, via your legacy configuration), even after deleting the DHCP reservation resource the IP is still available. You can retrieve it using the `scaleway_ipam_ip` datasource. For instance:
145+
146+
```hcl
147+
data "scaleway_ipam_ip" "existing" {
148+
mac_address = scaleway_instance_private_nic.main.mac_address
149+
type = "ipv4"
150+
}
151+
```
152+
153+
You can now use `data.scaleway_ipam_ip.existing.id` in your configuration to reference the reserved IP.
154+
155+
2. **Book New IPs Using the IPAM IP Resource**
156+
If you need to reserve new IPs, use the `scaleway_ipam_ip` resource. This resource allows you to explicitly book an IP from your private network. For example:
157+
158+
```hcl
159+
resource "scaleway_ipam_ip" "new_ip" {
160+
address = "192.168.1.1"
161+
source {
162+
private_network_id = scaleway_vpc_private_network.main.id
163+
}
164+
}
165+
```
166+
167+
3. **Attach the Reserved IP to Your Resources**
168+
169+
Once you have your IP—whether retrieved via the datasource or booked as a new resource—you can attach it to your server’s private NIC:
170+
171+
```hcl
172+
resource "scaleway_instance_private_nic" "pnic01" {
173+
private_network_id = scaleway_vpc_private_network.main.id
174+
server_id = scaleway_instance_server.main.id
175+
ipam_ip_ids = [scaleway_ipam_ip.new_ip.id]
176+
}
177+
```

0 commit comments

Comments
 (0)