Skip to content

Commit 200c4ff

Browse files
authored
Merge branch 'master' into errorlint
2 parents ccb4807 + ff87aee commit 200c4ff

File tree

111 files changed

+81390
-42720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+81390
-42720
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ linters:
7070
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
7171
- tagalign # check that struct tags are well aligned [fast: true, auto-fix: true]
7272
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
73-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
7473
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
7574
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
7675
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]

docs/data-sources/container.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,18 @@ In addition to all arguments above, the following attributes are exported:
9191

9292
- `deploy` - Boolean indicating whether the container is on a production environment.
9393

94+
- `sandbox` - Execution environment of the container.
95+
96+
- `heath_check` - Health check configuration block of the container.
97+
- `http` - HTTP health check configuration.
98+
- `path` - Path to use for the HTTP health check.
99+
- `failure_threshold` - Number of consecutive health check failures before considering the container unhealthy.
100+
- `interval`- Period between health checks (in seconds).
94101
- `sandbox` - (Optional) Execution environment of the container.
102+
- `scaling_option` - Configuration block used to decide when to scale up or down. Possible values:
103+
- `concurrent_requests_threshold` - Scale depending on the number of concurrent requests being processed per container instance.
104+
- `cpu_usage_threshold` - Scale depending on the CPU usage of a container instance.
105+
- `memory_usage_threshold`- Scale depending on the memory usage of a container instance.
95106

96107
- `status` - The container status.
97108

docs/resources/apple_silicon.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following arguments are supported:
3434

3535
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is
3636
associated with.
37+
- `enable_vpc` - (Optional, Default: false): Enables the VPC option when set to true.
3738

3839
## Attributes Reference
3940

@@ -50,6 +51,7 @@ In addition to all arguments above, the following attributes are exported:
5051
- `updated_at` - The date and time of the last update of the Apple Silicon server.
5152
- `deleted_at` - The minimal date and time on which you can delete this server due to Apple licence.
5253
- `organization_id` - The organization ID the server is associated with.
54+
- `vpc_status` - The current status of the VPC option.
5355

5456
## Import
5557

docs/resources/container.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ The following arguments are supported:
8484

8585
- `sandbox` - (Optional) Execution environment of the container.
8686

87+
- `heath_check` - (Optional) Health check configuration block of the container.
88+
- `http` - HTTP health check configuration.
89+
- `path` - Path to use for the HTTP health check.
90+
- `failure_threshold` - Number of consecutive health check failures before considering the container unhealthy.
91+
- `interval`- Period between health checks (in seconds).
92+
93+
- `scaling_option` - (Optional) Configuration block used to decide when to scale up or down. Possible values:
94+
- `concurrent_requests_threshold` - Scale depending on the number of concurrent requests being processed per container instance.
95+
- `cpu_usage_threshold` - Scale depending on the CPU usage of a container instance.
96+
- `memory_usage_threshold`- Scale depending on the memory usage of a container instance.
97+
8798
- `port` - (Optional) The port to expose the container.
8899

89100
- `deploy` - (Optional) Boolean indicating whether the container is in a production environment.
@@ -152,4 +163,56 @@ The `memory_limit` (in MB) must correspond with the right amount of vCPU. Refer
152163
| 4096 | 2240 |
153164

154165
~>**Important:** Make sure to select the right resources, as you will be billed based on compute usage over time and the number of Containers executions.
155-
Refer to the [Serverless Containers pricing](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) for more information.
166+
Refer to the [Serverless Containers pricing](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) for more information.
167+
168+
## Health check configuration
169+
170+
Custom health checks can be configured on the container.
171+
172+
It's possible to specify the HTTP path that the probe will listen to and the number of failures before considering the container as unhealthy.
173+
During a deployment, if a newly created container fails to pass the health check, the deployment is aborted.
174+
As a result, lowering this value can help to reduce the time it takes to detect a failed deployment.
175+
The period between health checks is also configurable.
176+
177+
Example:
178+
179+
```terraform
180+
resource scaleway_container main {
181+
name = "my-container-02"
182+
namespace_id = scaleway_container_namespace.main.id
183+
184+
health_check {
185+
http {
186+
path = "/ping"
187+
}
188+
failure_threshold = 40
189+
interval = "3s"
190+
}
191+
}
192+
```
193+
194+
~>**Important:** Another probe type can be set to TCP with the API, but currently the SDK has not been updated with this parameter.
195+
This is why the only probe that can be used here is the HTTP probe.
196+
Refer to the [Serverless Containers pricing](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) for more information.
197+
198+
## Scaling option configuration
199+
200+
Scaling option block configuration allows you to choose which parameter will scale up/down containers.
201+
Options are number of concurrent requests, CPU or memory usage.
202+
It replaces current `max_concurrency` that has been deprecated.
203+
204+
Example:
205+
206+
```terraform
207+
resource scaleway_container main {
208+
name = "my-container-02"
209+
namespace_id = scaleway_container_namespace.main.id
210+
211+
scaling_option {
212+
concurrent_requests_threshold = 15
213+
}
214+
}
215+
```
216+
217+
~>**Important**: A maximum of one of these parameters may be set. Also, when `cpu_usage_threshold` or `memory_usage_threshold` are used, `min_scale` can't be set to 0.
218+
Refer to the [API Reference](https://www.scaleway.com/en/developers/api/serverless-containers/#path-containers-create-a-new-container) for more information.

docs/resources/rdb_snapshot.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
subcategory: "Databases"
3+
page_title: "Scaleway: scaleway_rdb_snapshot"
4+
---
5+
6+
# Resource: scaleway_rdb_snapshot
7+
8+
Creates and manages Scaleway RDB (Relational Database) Snapshots.
9+
Snapshots are point-in-time backups of a database instance that can be used for recovery or duplication.
10+
For more information, refer to [the API documentation](https://www.scaleway.com/en/developers/api/managed-database-postgre-mysql/).
11+
12+
## Example Usage
13+
14+
### Example Basic Snapshot
15+
16+
```terraform
17+
resource "scaleway_rdb_instance" "main" {
18+
name = "test-rdb-instance"
19+
node_type = "db-dev-s"
20+
engine = "PostgreSQL-15"
21+
is_ha_cluster = false
22+
disable_backup = true
23+
user_name = "my_initial_user"
24+
password = "thiZ_is_v&ry_s3cret"
25+
tags = ["terraform-test", "scaleway_rdb_instance", "minimal"]
26+
volume_type = "bssd"
27+
volume_size_in_gb = 10
28+
}
29+
30+
resource "scaleway_rdb_snapshot" "test" {
31+
name = "initial-snapshot"
32+
instance_id = scaleway_rdb_instance.main.id
33+
depends_on = [scaleway_rdb_instance.main]
34+
}
35+
```
36+
37+
### Example with Expiration
38+
39+
```terraform
40+
resource "scaleway_rdb_snapshot" "snapshot_with_expiration" {
41+
name = "snapshot-with-expiration"
42+
instance_id = scaleway_rdb_instance.main.id
43+
expires_at = "2025-01-31T00:00:00Z"
44+
}
45+
```
46+
47+
### Example with Multiple Snapshots
48+
49+
```terraform
50+
resource "scaleway_rdb_snapshot" "snapshot_a" {
51+
name = "snapshot_a"
52+
instance_id = scaleway_rdb_instance.main.id
53+
depends_on = [scaleway_rdb_instance.main]
54+
}
55+
56+
resource "scaleway_rdb_snapshot" "snapshot_b" {
57+
name = "snapshot_b"
58+
instance_id = scaleway_rdb_instance.main.id
59+
expires_at = "2025-02-07T00:00:00Z"
60+
depends_on = [scaleway_rdb_instance.main]
61+
}
62+
```
63+
64+
## Argument Reference
65+
66+
The following arguments are supported:
67+
68+
- `name` - (Required) The name of the snapshot.
69+
- `instance_id` - (Required) The UUID of the database instance for which the snapshot is created.
70+
- `snapshot_id` - (Optional, ForceNew) The ID of an existing snapshot. This allows creating an instance from a specific snapshot ID. Conflicts with `engine`.
71+
- `expires_at` - (Optional) Expiration date of the snapshot in ISO 8601 format (e.g., `2025-01-31T00:00:00Z`). If not set, the snapshot will not expire automatically.
72+
73+
## Attributes Reference
74+
75+
In addition to all arguments above, the following attributes are exported:
76+
77+
- `id` - The unique ID of the snapshot.
78+
- `created_at` - The timestamp when the snapshot was created, in ISO 8601 format.
79+
- `updated_at` - The timestamp when the snapshot was last updated, in ISO 8601 format.
80+
- `status` - The current status of the snapshot (e.g., `ready`, `creating`, `error`).
81+
- `size` - The size of the snapshot in bytes.
82+
- `node_type` - The type of the database instance for which the snapshot was created.
83+
- `volume_type` - The type of volume used by the snapshot.
84+
85+
## Attributes Reference
86+
87+
- `region` - The region where the snapshot is stored. Defaults to the region set in the provider configuration.
88+
89+
## Import
90+
91+
RDB Snapshots can be imported using the `{region}/{snapshot_id}` format.
92+
93+
## Limitations
94+
95+
- Snapshots are tied to the database instance and region where they are created.
96+
- Expired snapshots are automatically deleted and cannot be restored.
97+
98+
## Notes
99+
100+
- Ensure the `instance_id` corresponds to an existing database instance.
101+
- Use the `depends_on` argument when creating snapshots right after creating an instance to ensure proper dependency management.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/nats-io/jwt/v2 v2.7.3
2929
github.com/nats-io/nats.go v1.38.0
3030
github.com/robfig/cron/v3 v3.0.1
31-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250117133139-e360c98f921d
31+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250206152403-1eed2f2ce9d3
3232
github.com/stretchr/testify v1.10.0
3333
golang.org/x/crypto v0.32.0
3434
gopkg.in/dnaeon/go-vcr.v3 v3.2.0
@@ -125,9 +125,9 @@ require (
125125
go.opentelemetry.io/otel/trace v1.31.0 // indirect
126126
golang.org/x/mod v0.22.0 // indirect
127127
golang.org/x/net v0.34.0 // indirect
128-
golang.org/x/sync v0.10.0 // indirect
128+
golang.org/x/sync v0.11.0 // indirect
129129
golang.org/x/sys v0.29.0 // indirect
130-
golang.org/x/text v0.21.0 // indirect
130+
golang.org/x/text v0.22.0 // indirect
131131
golang.org/x/time v0.3.0 // indirect
132132
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
133133
google.golang.org/appengine v1.6.8 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq
280280
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
281281
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
282282
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
283-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250117133139-e360c98f921d h1:npDtKGreHq1EA6DoHo18YG25bsvZVlo4XlNm822GZ7A=
284-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250117133139-e360c98f921d/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks=
283+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250206152403-1eed2f2ce9d3 h1:wNQbwsFYaWiqTRtAgO5uroCTsS0o8FPGdI/x4hCJqtM=
284+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250206152403-1eed2f2ce9d3/go.mod h1:792k1RTU+5JeMXm35/e2Wgp71qPH/DmDoZrRc+EFZDk=
285285
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
286286
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
287287
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
@@ -370,8 +370,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
370370
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
371371
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
372372
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
373-
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
374-
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
373+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
374+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
375375
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
376376
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
377377
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -401,8 +401,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
401401
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
402402
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
403403
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
404-
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
405-
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
404+
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
405+
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
406406
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
407407
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
408408
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ func Provider(config *Config) plugin.ProviderFunc {
207207
"scaleway_rdb_privilege": rdb.ResourcePrivilege(),
208208
"scaleway_rdb_read_replica": rdb.ResourceReadReplica(),
209209
"scaleway_rdb_user": rdb.ResourceUser(),
210+
"scaleway_rdb_snapshot": rdb.ResourceSnapshot(),
210211
"scaleway_redis_cluster": redis.ResourceCluster(),
211212
"scaleway_registry_namespace": registry.ResourceNamespace(),
212213
"scaleway_sdb_sql_database": sdb.ResourceDatabase(),

internal/services/applesilicon/clients.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ func NewAPIWithZoneAndID(m interface{}, id string) (*applesilicon.API, scw.Zone,
3131

3232
return asAPI, zone, ID, nil
3333
}
34+
35+
func newPrivateNetworkAPIWithZone(d *schema.ResourceData, m interface{}) (*applesilicon.PrivateNetworkAPI, scw.Zone, error) {
36+
privateNetworkAPI := applesilicon.NewPrivateNetworkAPI(meta.ExtractScwClient(m))
37+
38+
zone, err := meta.ExtractZone(d, m)
39+
if err != nil {
40+
return nil, "", err
41+
}
42+
43+
return privateNetworkAPI, zone, nil
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package applesilicon
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
8+
"github.com/scaleway/scaleway-sdk-go/scw"
9+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
10+
)
11+
12+
func detachAllPrivateNetworkFromServer(ctx context.Context, d *schema.ResourceData, m interface{}, serverID string) error {
13+
privateNetworkAPI, zone, err := newPrivateNetworkAPIWithZone(d, m)
14+
if err != nil {
15+
return err
16+
}
17+
18+
listPrivateNetwork, err := privateNetworkAPI.ListServerPrivateNetworks(&applesilicon.PrivateNetworkAPIListServerPrivateNetworksRequest{
19+
Zone: zone,
20+
ServerID: &serverID,
21+
}, scw.WithContext(ctx))
22+
if err != nil {
23+
return err
24+
}
25+
26+
for _, pn := range listPrivateNetwork.ServerPrivateNetworks {
27+
err := privateNetworkAPI.DeleteServerPrivateNetwork(&applesilicon.PrivateNetworkAPIDeleteServerPrivateNetworkRequest{
28+
Zone: zone,
29+
ServerID: serverID,
30+
PrivateNetworkID: pn.PrivateNetworkID,
31+
}, scw.WithContext(ctx))
32+
if err != nil {
33+
return err
34+
}
35+
}
36+
37+
_, err = waitForAppleSiliconPrivateNetworkServer(ctx, privateNetworkAPI, zone, serverID, d.Timeout(schema.TimeoutDelete))
38+
if err != nil && !httperrors.Is404(err) {
39+
return err
40+
}
41+
42+
return nil
43+
}

0 commit comments

Comments
 (0)