Skip to content

Commit 63b9a78

Browse files
committed
Fix
1 parent 440c498 commit 63b9a78

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

docs/resources/instance_server.md

+8-18
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,13 @@ resource "scaleway_instance_server" "web" {
100100

101101
```hcl
102102
resource "scaleway_instance_server" "web" {
103-
type = "DEV1-S"
103+
type = "DEV1-S"
104104
image = "ubuntu_focal"
105105
106-
tags = [ "web", "public" ]
107-
108-
user_data {
109-
key = "plop"
110-
value = "world"
111-
}
112-
113106
user_data {
114-
key = "xavier"
115-
value = "niel"
107+
foo = "bar"
108+
cloud-init = file("${path.module}/cloud-init.yml")
116109
}
117-
118-
cloud_init = file("${path.module}/cloud-init.yml")
119110
}
120111
```
121112

@@ -169,13 +160,12 @@ attached to the server. Updates to this field will trigger a stop/start of the s
169160

170161
- `state` - (Defaults to `started`) The state of the server. Possible values are: `started`, `stopped` or `standby`.
171162

172-
- `cloud_init` - (Optional) The cloud init script associated with this server. Updates to this field will trigger a stop/start of the server.
173-
174163
- `user_data` - (Optional) The user data associated with the server.
175-
176-
- `key` - (Required) The user data key. The `cloud-init` key is reserved, please use `cloud_init` attribute instead.
177-
178-
- `value` - (Required) The user data content. It could be a string or a file content using [file](https://www.terraform.io/docs/configuration/functions/file.html) or [filebase64](https://www.terraform.io/docs/configuration/functions/filebase64.html) for example.
164+
Use the `cloud-init` key to use [cloud-init](https://cloudinit.readthedocs.io/en/latest/) on your instance.
165+
You can define values using:
166+
- string
167+
- UTF-8 encoded file content using [file](https://www.terraform.io/docs/configuration/functions/file.html)
168+
- Binary files using [filebase64](https://www.terraform.io/docs/configuration/functions/filebase64.html).
179169

180170
- `boot_type` - The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`.
181171

scaleway/helpers_instance.go

-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package scaleway
33
import (
44
"context"
55
"fmt"
6-
"hash/crc32"
76
"sort"
87
"time"
98

@@ -62,28 +61,6 @@ func instanceAPIWithZoneAndNestedID(m interface{}, zonedNestedID string) (*insta
6261
return instanceAPI, zone, innerID, outerID, nil
6362
}
6463

65-
// hash hashes a string to a unique hashcode.
66-
//
67-
// crc32 returns a uint32, but for our use we need
68-
// and non negative integer. Here we cast to an integer
69-
// and invert it if the result is negative.
70-
func hash(s string) int {
71-
v := int(crc32.ChecksumIEEE([]byte(s)))
72-
if v >= 0 {
73-
return v
74-
}
75-
if -v >= 0 {
76-
return -v
77-
}
78-
// v == MinInt
79-
return 0
80-
}
81-
82-
func userDataHash(v interface{}) int {
83-
userData := v.(map[string]interface{})
84-
return hash(userData["key"].(string) + userData["value"].(string))
85-
}
86-
8764
// orderVolumes return an ordered slice based on the volume map key "0", "1", "2",...
8865
func orderVolumes(v map[string]*instance.Volume) []*instance.Volume {
8966
indexes := []string{}

0 commit comments

Comments
 (0)