Skip to content

Commit 83cfa19

Browse files
authored
docs(cockpit): migration doc for cockpit (#2867)
* doc: add migration doc for cockpit * doc(cockpit): add doc for migration cockpit resource
1 parent 7c34968 commit 83cfa19

File tree

1 file changed

+213
-0
lines changed

1 file changed

+213
-0
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
---
2+
page_title: "Migrating from Scaleway Cockpit to the New Infrastructure"
3+
---
4+
5+
# How to Migrate from Deprecated Resource `scaleway_cockpit` to `scaleway_cockpit_source`
6+
7+
## Overview
8+
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.
10+
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.
13+
14+
## Prerequisites
15+
16+
### Ensure the Latest Provider Version
17+
18+
Ensure your Scaleway provider is updated to at least version `2.49.0`.
19+
20+
```hcl
21+
terraform {
22+
required_providers {
23+
scaleway = {
24+
source = "scaleway/scaleway"
25+
version = "~> 2.49.0"
26+
}
27+
}
28+
}
29+
30+
provider "scaleway" {
31+
# Configuration details
32+
}
33+
```
34+
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`
44+
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:
46+
47+
#### Deprecated Resource: `scaleway_cockpit`
48+
49+
The following resource will no longer be supported after January 1st, 2025:
50+
51+
```hcl
52+
resource "scaleway_cockpit" "main" {
53+
project_id = "11111111-1111-1111-1111-111111111111"
54+
plan = "premium"
55+
}
56+
```
57+
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.
65+
66+
```hcl
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
90+
}
91+
```
92+
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:
96+
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+
}
105+
106+
contact_points {
107+
108+
}
109+
}
110+
```
111+
112+
**Grafana User:**
113+
114+
To retrieve the deprecated `grafana_url`, you must create a Grafana user. Creating the user will trigger the creation of the Grafana instance:
115+
116+
```hcl
117+
resource "scaleway_cockpit_grafana_user" "main" {
118+
project_id = scaleway_account_project.project.id
119+
login = "my-awesome-user"
120+
role = "editor"
121+
}
122+
```
123+
124+
### Notes on Regionalization
125+
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
132+
133+
```hcl
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
141+
}
142+
```
143+
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+
}
174+
175+
resource "scaleway_cockpit_grafana_user" "main" {
176+
project_id = scaleway_account_project.project.id
177+
login = "my-awesome-user"
178+
role = "editor"
179+
}
180+
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+
}
190+
```
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
200+
```
201+
202+
### Import a Grafana User
203+
204+
To import an existing Grafana user:
205+
206+
```bash
207+
terraform import scaleway_cockpit_grafana_user.main 11111111-1111-1111-1111-111111111111
208+
```
209+
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)