Skip to content

Commit 9cfdca4

Browse files
committed
doc(cockpit): add doc for migration cockpit resource
1 parent e56a4c3 commit 9cfdca4

File tree

1 file changed

+157
-54
lines changed

1 file changed

+157
-54
lines changed
Lines changed: 157 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,213 @@
11
---
2-
page_title: "Using Scaleway SSH Bastion"
2+
page_title: "Migrating from Scaleway Cockpit to the New Infrastructure"
33
---
44

5-
# How to use pass to depecated resource cockpit to new infra <- change ici le titre pour que se soit plus claire
5+
# How to Migrate from Deprecated Resource `scaleway_cockpit` to `scaleway_cockpit_source`
66

7-
-> voici l'explication : ducoup je fais un guide pour pouvoir supprimer la resource cockpit des terraforms et utiliser la nouvelle resource source, explique moi cela bien en anglais
8-
-> **Note:**
9-
Cockpit plans scheduled for deprecation on January 1st 2025.
10-
The retention period previously set for your logs and metrics will remain the same after that date.
11-
You will be able to edit the retention period for your metrics, logs, and traces for free during Beta.
7+
## Overview
128

9+
This guide provides a step-by-step process to remove the deprecated `scaleway_cockpit` resource from your Terraform configurations and transition to the new `scaleway_cockpit_source` resource. Note that this migration involves breaking down the functionalities of `scaleway_cockpit` into multiple specialized resources to manage endpoints effectively.
1310

14-
## Prerequisites
11+
> **Note:**
12+
> Scaleway Cockpit plans are scheduled for deprecation on **January 1st, 2025**. While the retention period for your logs and metrics will remain unchanged, you will be able to edit the retention period for metrics, logs, and traces for free during the Beta period.
1513
16-
d'abord il faut s'assurer d'avoir la dernier version du provider
17-
-> **Note:** Before upgrading to `v2+`, it is recommended to upgrade to the most recent `1.X` version of the provider (`v1.17.2`) and ensure that your environment successfully runs [`terraform plan`](https://www.terraform.io/docs/commands/plan.html) without unexpected change or deprecation notice.
14+
## Prerequisites
1815

19-
It is recommended to use [version constraints when configuring Terraform providers](https://www.terraform.io/language/providers/configuration#version-provider-versions).
20-
If you are following these recommendations, update the version constraints in your Terraform configuration and run [`terraform init`](https://www.terraform.io/docs/commands/init.html) to download the new version.
16+
### Ensure the Latest Provider Version
2117

22-
Update to latest `1.X` version:
18+
Ensure your Scaleway provider is updated to at least version `2.49.0`.
2319

2420
```hcl
2521
terraform {
2622
required_providers {
2723
scaleway = {
28-
source = "scaleway/scaleway"
29-
version = "~> 1.17"
24+
source = "scaleway/scaleway"
25+
version = "~> 2.49.0"
3026
}
3127
}
3228
}
3329
3430
provider "scaleway" {
35-
# ...
31+
# Configuration details
3632
}
3733
```
3834

39-
Update to latest 2.X version:
35+
Run the following command to initialize the updated provider:
36+
37+
```bash
38+
terraform init
39+
```
40+
41+
## Migrating Resources
42+
43+
### Transitioning from `scaleway_cockpit`
4044

41-
## Set up your Public Gateway
45+
The `scaleway_cockpit` resource is deprecated. Its functionalities, including endpoint management, are now divided across multiple specialized resources. Below are the steps to migrate:
4246

43-
Public Gateways sit at the border of Private Networks and allow you to enable the bastion.
44-
You can also choose your port of preference on `bastion_port` option. The default port is `61000`
47+
#### Deprecated Resource: `scaleway_cockpit`
4548

46-
You can check the types of gateways currently supported via our CLI.
49+
The following resource will no longer be supported after January 1st, 2025:
4750

48-
```shell
49-
scw vpc-gw gateway-type list
51+
```hcl
52+
resource "scaleway_cockpit" "main" {
53+
project_id = "11111111-1111-1111-1111-111111111111"
54+
plan = "premium"
55+
}
5056
```
5157

52-
Example:
58+
#### New Resources
59+
60+
To handle specific functionalities previously managed by `scaleway_cockpit`, you need to use the following resources:
61+
62+
**Data Source Management:**
63+
64+
In the deprecated `scaleway_cockpit` resource, the `plan` argument determined the retention period for logs, metrics, and traces. Now, retention periods are set individually for each data source using the `retention_days` argument in `scaleway_cockpit_source` resources.
5365

5466
```hcl
55-
resource scaleway_vpc_public_gateway "pgw" {
56-
type = "VPC-GW-S"
57-
bastion_enabled = true
58-
ip_id = scaleway_vpc_public_gateway_ip.pgw_ip.id
67+
resource "scaleway_account_project" "project" {
68+
name = "test project data source"
69+
}
70+
71+
resource "scaleway_cockpit_source" "metrics" {
72+
project_id = scaleway_account_project.project.id
73+
name = "metrics-source"
74+
type = "metrics"
75+
retention_days = 6 # Customize retention period (1-365 days)
76+
}
77+
78+
resource "scaleway_cockpit_source" "logs" {
79+
project_id = scaleway_account_project.project.id
80+
name = "logs-source"
81+
type = "logs"
82+
retention_days = 30
83+
}
84+
85+
resource "scaleway_cockpit_source" "traces" {
86+
project_id = scaleway_account_project.project.id
87+
name = "traces-source"
88+
type = "traces"
89+
retention_days = 15
5990
}
6091
```
6192

62-
## Configure your DHCP on your subnet
93+
**Alert Manager:**
94+
95+
To retrieve the deprecated `alertmanager_url`, you must now explicitly create an Alert Manager using the `scaleway_cockpit_alert_manager` resource:
6396

64-
The [DHCP](https://fr.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol) server sets the IPv4 address dynamically,
65-
which is required to communicate over the private network.
97+
```hcl
98+
resource "scaleway_cockpit_alert_manager" "alert_manager" {
99+
project_id = scaleway_account_project.project.id
100+
enable_managed_alerts = true
101+
102+
contact_points {
103+
104+
}
66105
67-
The `dns_local_name` is the [TLD](https://en.wikipedia.org/wiki/Top-level_domain), the value by default is `priv`.
68-
This is used to resolve your Instance on a Private Network.
106+
contact_points {
107+
108+
}
109+
}
110+
```
69111

70-
In order to resolve the Instances using your Bastion you should set the `dns_local_name` with `scaleway_vpc_private_network.pn.name`.
112+
**Grafana User:**
71113

72-
Please check our API [documentation](https://www.scaleway.com/en/developers/api/public-gateway/#path-dhcp-create-a-dhcp-configuration) for more details.
114+
To retrieve the deprecated `grafana_url`, you must create a Grafana user. Creating the user will trigger the creation of the Grafana instance:
73115

74116
```hcl
75-
resource scaleway_vpc_public_gateway_dhcp "dhcp" {
76-
subnet = "192.168.1.0/24"
77-
dns_local_name = scaleway_vpc_private_network.pn.name
117+
resource "scaleway_cockpit_grafana_user" "main" {
118+
project_id = scaleway_account_project.project.id
119+
login = "my-awesome-user"
120+
role = "editor"
78121
}
79122
```
80123

81-
## Attach your VPC Gateway Network to a Private Network
124+
### Notes on Regionalization
82125

83-
To enable DHCP on this Private Network you must set `enable_dhcp` and `dhcp_id`.
84-
Do not set the `address` attribute.
126+
- As of September 2024, Cockpit resources are regionalized for improved flexibility and resilience. Update your queries in Grafana to use the new regionalized data sources.
127+
- Metrics, logs, and traces now have dedicated resources that allow granular control over retention policies.
128+
129+
### Before and After Example
130+
131+
#### Before: Using `scaleway_cockpit` to Retrieve Endpoints
85132

86133
```hcl
87-
resource scaleway_vpc_gateway_network "gn" {
88-
gateway_id = scaleway_vpc_public_gateway.pgw.id
89-
private_network_id = scaleway_vpc_private_network.pn.id
90-
dhcp_id = scaleway_vpc_public_gateway_dhcp.dhcp.id
91-
enable_dhcp = true
134+
resource "scaleway_cockpit" "main" {
135+
project_id = "11111111-1111-1111-1111-111111111111"
136+
plan = "premium"
137+
}
138+
139+
output "endpoints" {
140+
value = scaleway_cockpit.main.endpoints
92141
}
93142
```
94143

95-
## Config my Bastion config
144+
#### After: Using Specialized Resources
145+
146+
To retrieve all endpoints (metrics, logs, traces, alert manager, and Grafana):
147+
148+
```hcl
149+
resource "scaleway_cockpit_source" "metrics" {
150+
project_id = scaleway_account_project.project.id
151+
name = "metrics-source"
152+
type = "metrics"
153+
retention_days = 6
154+
}
155+
156+
resource "scaleway_cockpit_source" "logs" {
157+
project_id = scaleway_account_project.project.id
158+
name = "logs-source"
159+
type = "logs"
160+
retention_days = 30
161+
}
162+
163+
resource "scaleway_cockpit_source" "traces" {
164+
project_id = scaleway_account_project.project.id
165+
name = "traces-source"
166+
type = "traces"
167+
retention_days = 15
168+
}
169+
170+
resource "scaleway_cockpit_alert_manager" "alert_manager" {
171+
project_id = scaleway_account_project.project.id
172+
enable_managed_alerts = true
173+
}
96174
97-
You should add your config on your local config file e.g: `~/.ssh/config`
175+
resource "scaleway_cockpit_grafana_user" "main" {
176+
project_id = scaleway_account_project.project.id
177+
login = "my-awesome-user"
178+
role = "editor"
179+
}
98180
181+
output "endpoints" {
182+
value = {
183+
metrics = scaleway_cockpit_source.metrics.url
184+
logs = scaleway_cockpit_source.logs.url
185+
traces = scaleway_cockpit_source.traces.url
186+
alert_manager = scaleway_cockpit_alert_manager.alert_manager.alert_manager_url
187+
grafana = scaleway_cockpit_grafana_user.main.grafana_url
188+
}
189+
}
99190
```
100-
Host *.myprivatenetwork
101-
ProxyJump bastion@<your-public-ip>:<bastion_port>
191+
192+
## Importing Resources
193+
194+
### Import a Cockpit Source
195+
196+
To import an existing `scaleway_cockpit_source` resource:
197+
198+
```bash
199+
terraform import scaleway_cockpit_source.main fr-par/11111111-1111-1111-1111-111111111111
102200
```
103201

104-
Then try to connect to it:
202+
### Import a Grafana User
105203

106-
```shell
107-
ssh root@<vm-name>.myprivatenetwork
204+
To import an existing Grafana user:
205+
206+
```bash
207+
terraform import scaleway_cockpit_grafana_user.main 11111111-1111-1111-1111-111111111111
108208
```
109209

110-
For further information using our console please check [our dedicated documentation](https://www.scaleway.com/en/docs/network/vpc/how-to/use-ssh-bastion/).
210+
## Conclusion
211+
212+
By following this guide, you can successfully transition from the deprecated `scaleway_cockpit` resource to the new set of specialized resources. This ensures compatibility with the latest Terraform provider and Scaleway's updated infrastructure.
213+

0 commit comments

Comments
 (0)