Skip to content

Commit 4fb3307

Browse files
authored
Merge branch 'master' into feat/creating_instance_from_snapshot
2 parents 8ecd676 + 9669d4c commit 4fb3307

File tree

6 files changed

+582
-350
lines changed

6 files changed

+582
-350
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+

docs/resources/object_bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ If you make any change to your bucket's tags using the console, it will overwrit
141141
* `expose_headers` (Optional) Specifies header exposure in the response.
142142
* `max_age_seconds` (Optional) Specifies time in seconds that the browser can cache the response for a preflight request.
143143

144-
* `force_destroy` - (Optional) Whether to allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has object lock enabled.
144+
* `force_destroy` - (Optional) Boolean that, when set to true, allows the deletion of all objects (including locked objects) when the bucket is destroyed. This operation is irreversible, and the objects cannot be recovered. The default is false.
145145

146146
* `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the bucket is associated with.
147147

docs/resources/vpc_public_gateway_dhcp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ page_title: "Scaleway: scaleway_vpc_public_gateway_dhcp"
55

66
# Resource: scaleway_vpc_public_gateway_dhcp
77

8+
9+
810
Creates and manages Scaleway VPC Public Gateway DHCP configurations.
911
For more information, see [the documentation](https://www.scaleway.com/en/developers/api/public-gateway/#dhcp-c05544).
1012

@@ -31,6 +33,9 @@ The following arguments are supported:
3133
- `renew_timer` - (Optional) After how long, in seconds, a renewal will be attempted. Must be 30s lower than `rebind_timer`. Defaults to 50m (3000s).
3234
- `rebind_timer` - (Optional) After how long, in seconds, a DHCP client will query for a new lease if previous renews fail. Must be 30s lower than `valid_lifetime`. Defaults to 51m (3060s).
3335
- `push_default_route` - (Optional) Whether the gateway should push a default route to DHCP clients or only hand out IPs. Defaults to `true`.
36+
37+
~> **Warning**: If you need to setup a default route, it's recommended to use the [`scaleway_vpc_gateway_network`](vpc_gateway_network.md#create-a-gatewaynetwork-with-ipam-configuration) resource instead.
38+
3439
- `push_dns_server` - (Optional) Whether the gateway should push custom DNS servers to clients. This allows for instance hostname -> IP resolution. Defaults to `true`.
3540
- `dns_servers_override` - (Optional) Override the DNS server list pushed to DHCP clients, instead of the gateway itself.
3641
- `dns_search` - (Optional) Additional DNS search paths

internal/services/k8s/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ func ResourceK8SClusterUpdate(ctx context.Context, d *schema.ResourceData, m int
650650
}
651651

652652
if d.HasChange("description") {
653-
updateRequest.Description = types.ExpandStringPtr(d.Get("description"))
653+
updateRequest.Description = types.ExpandUpdatedStringPtr(d.Get("description"))
654654
}
655655

656656
if d.HasChange("tags") {

internal/services/k8s/cluster_test.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,19 @@ func TestAccCluster_Basic(t *testing.T) {
8787
),
8888
Steps: []resource.TestStep{
8989
{
90-
Config: testAccCheckK8SClusterConfigMinimal(previousK8SVersion),
90+
Config: fmt.Sprintf(`
91+
resource "scaleway_vpc_private_network" "minimal" {
92+
name = "test-minimal"
93+
}
94+
resource "scaleway_k8s_cluster" "minimal" {
95+
cni = "calico"
96+
version = "%s"
97+
name = "test-minimal"
98+
tags = [ "terraform-test", "scaleway_k8s_cluster", "minimal" ]
99+
delete_additional_resources = false
100+
private_network_id = scaleway_vpc_private_network.minimal.id
101+
description = "terraform basic test cluster"
102+
}`, previousK8SVersion),
91103
Check: resource.ComposeTestCheckFunc(
92104
testAccCheckK8SClusterExists(tt, "scaleway_k8s_cluster.minimal"),
93105
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "version", previousK8SVersion),
@@ -102,10 +114,22 @@ func TestAccCluster_Basic(t *testing.T) {
102114
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.0", "terraform-test"),
103115
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.1", "scaleway_k8s_cluster"),
104116
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.2", "minimal"),
117+
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "description", "terraform basic test cluster"),
105118
),
106119
},
107120
{
108-
Config: testAccCheckK8SClusterConfigMinimal(latestK8SVersion),
121+
Config: fmt.Sprintf(`
122+
resource "scaleway_vpc_private_network" "minimal" {
123+
name = "test-minimal"
124+
}
125+
resource "scaleway_k8s_cluster" "minimal" {
126+
cni = "calico"
127+
version = "%s"
128+
name = "test-minimal"
129+
tags = [ "terraform-test", "scaleway_k8s_cluster", "minimal" ]
130+
delete_additional_resources = false
131+
private_network_id = scaleway_vpc_private_network.minimal.id
132+
}`, latestK8SVersion),
109133
Check: resource.ComposeTestCheckFunc(
110134
testAccCheckK8SClusterExists(tt, "scaleway_k8s_cluster.minimal"),
111135
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "version", latestK8SVersion),
@@ -120,6 +144,7 @@ func TestAccCluster_Basic(t *testing.T) {
120144
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.0", "terraform-test"),
121145
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.1", "scaleway_k8s_cluster"),
122146
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "tags.2", "minimal"),
147+
resource.TestCheckResourceAttr("scaleway_k8s_cluster.minimal", "description", ""),
123148
),
124149
},
125150
},
@@ -600,21 +625,6 @@ func testAccCheckK8sClusterPrivateNetworkID(tt *acctest.TestTools, clusterName,
600625
}
601626
}
602627

603-
func testAccCheckK8SClusterConfigMinimal(version string) string {
604-
return fmt.Sprintf(`
605-
resource "scaleway_vpc_private_network" "minimal" {
606-
name = "test-minimal"
607-
}
608-
resource "scaleway_k8s_cluster" "minimal" {
609-
cni = "calico"
610-
version = "%s"
611-
name = "test-minimal"
612-
tags = [ "terraform-test", "scaleway_k8s_cluster", "minimal" ]
613-
delete_additional_resources = false
614-
private_network_id = scaleway_vpc_private_network.minimal.id
615-
}`, version)
616-
}
617-
618628
func testAccCheckK8SClusterConfigAutoscaler(version string) string {
619629
return fmt.Sprintf(`
620630
resource "scaleway_vpc_private_network" "autoscaler" {

0 commit comments

Comments
 (0)