Skip to content

Commit aa1f090

Browse files
Lichard TormanClément Decoodt
Lichard Torman
and
Clément Decoodt
authored
feat(iot): add hub devices support (#508)
Co-authored-by: Clément Decoodt <[email protected]>
1 parent 7200d6d commit aa1f090

6 files changed

+2023
-0
lines changed

docs/resources/iot_device.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: scaleway_iot_hub_device"
4+
description: |-
5+
Manages Scaleway IoT Hub device.
6+
---
7+
8+
# scaleway_iot_hub_device
9+
10+
-> **Note:** This terraform resource is currently in beta and might include breaking change in future releases.
11+
12+
Creates and manages Scaleway IoT Hub Instances. For more information, see [the documentation](https://developers.scaleway.com/en/products/iot/api).
13+
14+
## Examples
15+
16+
### Basic
17+
18+
```hcl
19+
resource scaleway_iot_hub main {
20+
name = "test-iot"
21+
product_plan = "plan_shared"
22+
}
23+
24+
resource scaleway_iot_hub_device main {
25+
hub_id = scaleway_iot_hub.main.id
26+
name = "test-iot"
27+
}
28+
```
29+
30+
## Arguments Reference
31+
32+
The following arguments are supported:
33+
34+
- `hub_id` - (Required) The ID of the hub on which this device will be created.
35+
36+
- `name` - (Required) The name of the IoT device you want to create (e.g. `my-device`).
37+
38+
~> **Important:** Updates to `name` will destroy and recreate a new resource.
39+
40+
- `description` - (Optional) The description of the IoT device (e.g. `living room`).
41+
42+
- `allow_insecure` - (Optional) Allow plain and server-authenticated TLS connections in addition to mutually-authenticated ones.
43+
44+
~> **Important:** Updates to `allow_insecure` can disconnect eventually connected devices.
45+
46+
- `allow_multiple_connections` - (Optional) Allow more than one simultaneous connection using the same device credentials.
47+
48+
~> **Important:** Updates to `allow_multiple_connections` can disconnect eventually connected devices.
49+
50+
- `message_filters` - (Optional) Rules that define which messages are authorized or denied based on their topic.
51+
- `publish` - (Optional) Rules used to restrict topics the device can publish to.
52+
- `policy` (Optional) Filtering policy (eg `accept` or `reject`)
53+
- `topics` (Optional) List of topics to match (eg `foo/bar/+/baz/#`)
54+
- `subscribe` - (Optional) Rules used to restrict topics the device can subscribe to.
55+
- `policy` (Optional) Same as publish rules.
56+
- `topics` (Optional) Same as publish rules.
57+
58+
59+
## Attributes Reference
60+
61+
In addition to all arguments above, the following attributes are exported:
62+
63+
- `id` - The ID of the device.
64+
- `created_at` - The date and time the device was created.
65+
- `updated_at` - The date and time the device resource was updated.
66+
- `certificate` - The certificate bundle of the device.
67+
- `crt` - The certificate of the device.
68+
- `key` - The private key of the device.
69+
- `status` - The current status of the device.
70+
- `last_activity_at` - The last MQTT activity of the device.
71+
- `is_connected` - The current connection status of the device.
72+
73+
74+
## Import
75+
76+
IoT devices can be imported using the `{region}/{id}`, e.g.
77+
78+
```bash
79+
$ terraform import scaleway_iot_device.device01 fr-par/11111111-1111-1111-1111-111111111111
80+
```

scaleway/helpers.go

+11
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,17 @@ func expandStrings(data interface{}) []string {
327327
return stringSlice
328328
}
329329

330+
func expandStringsOrEmpty(data interface{}) []string {
331+
if data == nil {
332+
return []string{}
333+
}
334+
stringSlice := []string{}
335+
for _, s := range data.([]interface{}) {
336+
stringSlice = append(stringSlice, s.(string))
337+
}
338+
return stringSlice
339+
}
340+
330341
func expandSliceStringPtr(data interface{}) []*string {
331342
if data == nil {
332343
return nil

scaleway/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func Provider(config *ProviderConfig) plugin.ProviderFunc {
7676
"scaleway_instance_placement_group": resourceScalewayInstancePlacementGroup(),
7777
"scaleway_instance_private_nic": resourceScalewayInstancePrivateNIC(),
7878
"scaleway_iot_hub": resourceScalewayIotHub(),
79+
"scaleway_iot_device": resourceScalewayIotDevice(),
7980
"scaleway_k8s_cluster": resourceScalewayK8SCluster(),
8081
"scaleway_k8s_pool": resourceScalewayK8SPool(),
8182
"scaleway_lb": resourceScalewayLb(),

0 commit comments

Comments
 (0)