Skip to content

Commit 32b998b

Browse files
authored
Merge branch 'master' into devcontainer
2 parents d988f1e + 5bba67b commit 32b998b

35 files changed

+12502
-1405
lines changed

docs/data-sources/baremetal_os.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ description: |-
99
Gets information about a baremetal operating system.
1010
For more information, see [the documentation](https://developers.scaleway.com/en/products/baremetal/api).
1111

12+
You can also use the [scaleway-cli](https://github.com/scaleway/scaleway-cli) with `scw baremetal os list` to list all available operating systems.
13+
1214
## Example Usage
1315

1416
```hcl
1517
# Get info by os name and version
1618
data "scaleway_baremetal_os" "by_name" {
1719
name = "Ubuntu"
18-
version = "20.04"
20+
version = "20.04 LTS (Focal Fossa)"
1921
}
2022
2123
# Get info by os id

docs/data-sources/iot_device.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: scaleway_iot_device"
4+
description: |-
5+
Gets information about an IOT Device.
6+
---
7+
8+
# scaleway_iot_device
9+
10+
Gets information about an IOT Device.
11+
12+
## Example Usage
13+
14+
```hcl
15+
# Get info by name
16+
data "scaleway_iot_device" "my_device" {
17+
name = "foobar"
18+
}
19+
20+
# Get info by name and hub_id
21+
data "scaleway_iot_device" "my_device" {
22+
name = "foobar"
23+
hub_id = "11111111-1111-1111-1111-111111111111"
24+
}
25+
26+
# Get info by device ID
27+
data "scaleway_iot_device" "my_device" {
28+
device_id = "11111111-1111-1111-1111-111111111111"
29+
}
30+
31+
```
32+
33+
## Argument Reference
34+
35+
- `name` - (Optional) The name of the Hub.
36+
Only one of the `name` and `device_id` should be specified.
37+
38+
- `hub_id` - (Optional) The hub ID.
39+
40+
- `device_id` - (Optional) The device ID.
41+
Only one of the `name` and `device_id` should be specified.
42+
43+
- `region` - (Default to [provider](../index.md) `region`) The [region](../guides/regions_and_zones.md#zones) in which the hub exists.

docs/data-sources/iot_hub.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: scaleway_iot_hub"
4+
description: |-
5+
Gets information about an IOT Hub.
6+
---
7+
8+
# scaleway_iot_hub
9+
10+
Gets information about an IOT Hub.
11+
12+
## Example Usage
13+
14+
```hcl
15+
# Get info by name
16+
data "scaleway_iot_hub" "my_hub" {
17+
name = "foobar"
18+
}
19+
20+
# Get info by hub ID
21+
data "scaleway_iot_hub" "my_hub" {
22+
hub_id = "11111111-1111-1111-1111-111111111111"
23+
}
24+
25+
```
26+
27+
## Argument Reference
28+
29+
- `name` - (Optional) The name of the Hub.
30+
Only one of the `name` and `hub_id` should be specified.
31+
32+
- `hub_id` - (Optional) The Hub ID.
33+
Only one of the `name` and `hub_id` should be specified.
34+
35+
- `region` - (Default to [provider](../index.md) `region`) The [region](../guides/regions_and_zones.md#zones) in which the hub exists.
36+
37+
- `project_id` - (Default to [provider](../index.md) `project_id`)

docs/resources/redis_cluster.md

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
page_title: "Scaleway: scaleway_redis_cluster"
3+
description: |-
4+
Manages Scaleway Redis Clusters.
5+
---
6+
7+
# scaleway_redis_cluster
8+
9+
Creates and manages Scaleway Redis Clusters.
10+
For more information, see [the documentation](https://developers.scaleway.com/en/products/redis/api).
11+
12+
## Examples
13+
14+
### Basic
15+
16+
```hcl
17+
resource "scaleway_redis_cluster" "main" {
18+
name = "test_redis_basic"
19+
version = "6.2.6"
20+
node_type = "MDB-BETA-M"
21+
user_name = "my_initial_user"
22+
password = "thiZ_is_v&ry_s3cret"
23+
tags = [ "test", "redis" ]
24+
cluster_size = 1
25+
tls_enabled = "true"
26+
27+
acl {
28+
ip = "0.0.0.0/0"
29+
description = "Allow all"
30+
}
31+
}
32+
```
33+
34+
### With settings
35+
36+
```hcl
37+
resource "scaleway_redis_cluster" "main" {
38+
name = "test_redis_basic"
39+
version = "6.2.6"
40+
node_type = "MDB-BETA-M"
41+
user_name = "my_initial_user"
42+
password = "thiZ_is_v&ry_s3cret"
43+
44+
settings = {
45+
"maxclients" = "1000"
46+
"tcp-keepalive" = "120"
47+
}
48+
}
49+
```
50+
51+
## Arguments Reference
52+
53+
The following arguments are supported:
54+
55+
- `version` - (Required) Redis's Cluster version (e.g. `6.2.6`).
56+
57+
~> **Important:** Updates to `version` will migrate the Redis Cluster to the desired `version`. Keep in mind that you cannot downgrade a Redis Cluster.
58+
59+
- `node_type` - (Required) The type of Redis Cluster you want to create (e.g. `MDB-BETA-M`).
60+
61+
~> **Important:** Updates to `node_type` will migrate the Redis Cluster to the desired `node_type`. Keep in mind that you cannot downgrade a Redis Cluster.
62+
63+
- `user_name` - (Required) Identifier for the first user of the Redis Cluster.
64+
65+
- `password` - (Required) Password for the first user of the Redis Cluster.
66+
67+
- `name` - (Optional) The name of the Redis Cluster.
68+
69+
- `tags` - (Optional) The tags associated with the Redis Cluster.
70+
71+
- `zone` - (Defaults to [provider](../index.md) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the Redis Cluster should be created.
72+
73+
- `cluster_size` - (Optional) The number of nodes in the Redis Cluster.
74+
75+
~> **Important:** You can set a bigger `cluster_size`, it will migrate the Redis Cluster, but keep in mind that you cannot downgrade a Redis Cluster so setting a smaller `cluster_size` will not have any effect.
76+
77+
- `tls_enabled` - (Defaults to false) Whether TLS is enabled or not.
78+
79+
- `project_id` - (Defaults to [provider](../index.md) `project_id`) The ID of the project the Redis Cluster is associated with.
80+
81+
- `acl` - (Optional) List of acl rules, this is cluster's authorized IPs.
82+
83+
The `acl` block supports:
84+
85+
- `ip` - (Required) The ip range to whitelist in [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation)
86+
- `description` - (Optional) A text describing this rule. Default description: `Allow IP`
87+
88+
- `settings` - (Optional) Map of settings for redis cluster. Available settings can be found by listing redis versions with scaleway API or CLI
89+
90+
## Attributes Reference
91+
92+
In addition to all arguments above, the following attributes are exported:
93+
94+
- `id` - The ID of the Database Instance.
95+
- `created_at` - The date and time of creation of the Redis Cluster.
96+
- `updated_at` - The date and time of the last update of the Redis Cluster.
97+
98+
99+
## Import
100+
101+
Redis Cluster can be imported using the `{zone}/{id}`, e.g.
102+
103+
```bash
104+
$ terraform import scaleway_redis_cluster.redis01 fr-par/11111111-1111-1111-1111-111111111111
105+
```

docs/resources/vpc_gateway_network.md

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "scaleway_vpc_public_gateway_ip" "gw01" {
2222
2323
resource "scaleway_vpc_public_gateway_dhcp" "dhcp01" {
2424
subnet = "192.168.1.0/24"
25+
push_default_route = true
2526
}
2627
2728
resource "scaleway_vpc_public_gateway" "pg01" {
@@ -34,6 +35,8 @@ resource "scaleway_vpc_gateway_network" "main" {
3435
gateway_id = scaleway_vpc_public_gateway.pg01.id
3536
private_network_id = scaleway_vpc_private_network.pn01.id
3637
dhcp_id = scaleway_vpc_public_gateway_dhcp.dhcp01.id
38+
cleanup_dhcp = true
39+
enable_masquerade = true
3740
}
3841
```
3942

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/scaleway/terraform-provider-scaleway/v2
22

33
require (
4-
github.com/aws/aws-sdk-go v1.43.39
4+
github.com/aws/aws-sdk-go v1.44.4
55
github.com/dnaeon/go-vcr v1.2.0
66
github.com/docker/docker v20.10.14+incompatible
77
github.com/dustin/go-humanize v1.0.0
8-
github.com/google/go-cmp v0.5.7
8+
github.com/google/go-cmp v0.5.8
99
github.com/hashicorp/aws-sdk-go-base v1.1.0
1010
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1111
github.com/hashicorp/go-retryablehttp v0.7.1

go.sum

+4-3
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
127127
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
128128
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
129129
github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
130-
github.com/aws/aws-sdk-go v1.43.39 h1:5W8pton/8OuS5hpbAkzfr7e+meAAFkK7LsUehB39L3I=
131-
github.com/aws/aws-sdk-go v1.43.39/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
130+
github.com/aws/aws-sdk-go v1.44.4 h1:ePN0CVJMdiz2vYUcJH96eyxRrtKGSDMgyhP6rah2OgE=
131+
github.com/aws/aws-sdk-go v1.44.4/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
132132
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
133133
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
134134
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -481,8 +481,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
481481
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
482482
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
483483
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
484-
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
485484
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
485+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
486+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
486487
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
487488
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
488489
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=

scaleway/data_source_baremetal_os.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ func dataSourceScalewayBaremetalOsRead(ctx context.Context, d *schema.ResourceDa
7979

8080
zoneID := datasourceNewZonedID(osID, zone)
8181
d.SetId(zoneID)
82-
err = d.Set("os_id", zoneID)
83-
if err != nil {
84-
return diag.FromErr(err)
85-
}
8682

83+
_ = d.Set("os_id", zoneID)
8784
_ = d.Set("zone", zone)
8885
_ = d.Set("name", osName)
8986
_ = d.Set("version", osVersion)

scaleway/data_source_baremetal_os_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAccScalewayDataSourceBaremetalOS_Basic(t *testing.T) {
2222
Config: `
2323
data "scaleway_baremetal_os" "by_name" {
2424
name = "Ubuntu"
25-
version = "20.04"
25+
version = "20.04 LTS (Focal Fossa)"
2626
}
2727
2828
data "scaleway_baremetal_os" "by_id" {

scaleway/data_source_iot_device.go

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package scaleway
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
"github.com/scaleway/scaleway-sdk-go/api/iot/v1"
9+
)
10+
11+
func dataSourceScalewayIotDevice() *schema.Resource {
12+
dsSchema := datasourceSchemaFromResourceSchema(resourceScalewayIotDevice().Schema)
13+
14+
addOptionalFieldsToSchema(dsSchema, "name", "region")
15+
16+
dsSchema["name"].ConflictsWith = []string{"device_id"}
17+
dsSchema["hub_id"].Optional = true
18+
dsSchema["device_id"] = &schema.Schema{
19+
Type: schema.TypeString,
20+
Optional: true,
21+
Description: "The ID of the IOT Device",
22+
ConflictsWith: []string{"name"},
23+
ValidateFunc: validationUUIDorUUIDWithLocality(),
24+
}
25+
26+
return &schema.Resource{
27+
ReadContext: dataSourceScalewayIotDeviceRead,
28+
Schema: dsSchema,
29+
}
30+
}
31+
32+
func dataSourceScalewayIotDeviceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
33+
api, region, err := iotAPIWithRegion(d, meta)
34+
if err != nil {
35+
return diag.FromErr(err)
36+
}
37+
38+
deviceID, ok := d.GetOk("device_id")
39+
if !ok {
40+
hubID, hubIDExists := d.GetOk("hub_id")
41+
if hubIDExists {
42+
_, hubID, err = parseRegionalID(hubID.(string))
43+
if err != nil {
44+
return diag.FromErr(err)
45+
}
46+
}
47+
res, err := api.ListDevices(&iot.ListDevicesRequest{
48+
Region: region,
49+
Name: expandStringPtr(d.Get("name")),
50+
HubID: expandStringPtr(hubID),
51+
})
52+
if err != nil {
53+
return diag.FromErr(err)
54+
}
55+
for _, device := range res.Devices {
56+
if device.Name == d.Get("name").(string) {
57+
if deviceID != "" {
58+
return diag.Errorf("more than 1 device with the same name %s", d.Get("name"))
59+
}
60+
deviceID = device.ID
61+
}
62+
}
63+
if deviceID == "" {
64+
return diag.Errorf("no device found with the name %s", d.Get("name"))
65+
}
66+
}
67+
68+
regionalID := datasourceNewRegionalizedID(deviceID, region)
69+
d.SetId(regionalID)
70+
err = d.Set("device_id", regionalID)
71+
if err != nil {
72+
return diag.FromErr(err)
73+
}
74+
diags := resourceScalewayIotDeviceRead(ctx, d, meta)
75+
if diags != nil {
76+
return diags
77+
}
78+
if d.Id() == "" {
79+
return diag.Errorf("IOT Device not found (%s)", regionalID)
80+
}
81+
return nil
82+
}

0 commit comments

Comments
 (0)