Skip to content

Commit c5ca20a

Browse files
authored
feat(instance_volume): add scratch type (#2122)
* feat(instance_volume): add scratch type * update doc
1 parent 6fefc99 commit c5ca20a

4 files changed

+256
-2
lines changed

docs/resources/instance_volume.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ resource "scaleway_instance_volume" "server_volume" {
2222

2323
The following arguments are supported:
2424

25-
- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD).
25+
- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).
2626
- `size_in_gb` - (Optional) The size of the volume. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
2727
- `from_volume_id` - (Optional) If set, the new volume will be copied from this volume. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
28-
- ``from_snapshot_id`` - (Optional) If set, the new volume will be created from this snapshot. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
28+
- `from_snapshot_id` - (Optional) If set, the new volume will be created from this snapshot. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
2929
- `name` - (Optional) The name of the volume. If not provided it will be randomly generated.
3030
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the volume should be created.
3131
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the volume is associated with.

scaleway/resource_instance_volume.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func resourceScalewayInstanceVolume() *schema.Resource {
4141
ValidateFunc: validation.StringInSlice([]string{
4242
instance.VolumeVolumeTypeBSSD.String(),
4343
instance.VolumeVolumeTypeLSSD.String(),
44+
instance.VolumeVolumeTypeScratch.String(),
4445
}, false),
4546
},
4647
"size_in_gb": {

scaleway/resource_instance_volume_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,25 @@ func TestAccScalewayInstanceVolume_CannotResizeBlockDown(t *testing.T) {
235235
})
236236
}
237237

238+
func TestAccScalewayInstanceVolume_Scratch(t *testing.T) {
239+
tt := NewTestTools(t)
240+
defer tt.Cleanup()
241+
resource.ParallelTest(t, resource.TestCase{
242+
PreCheck: func() { testAccPreCheck(t) },
243+
ProviderFactories: tt.ProviderFactories,
244+
CheckDestroy: testAccCheckScalewayInstanceVolumeDestroy(tt),
245+
Steps: []resource.TestStep{
246+
{
247+
Config: `
248+
resource "scaleway_instance_volume" "main" {
249+
type = "scratch"
250+
size_in_gb = 20
251+
}`,
252+
},
253+
},
254+
})
255+
}
256+
238257
func testAccCheckScalewayInstanceVolumeExists(tt *TestTools, n string) resource.TestCheckFunc {
239258
return func(s *terraform.State) error {
240259
rs, ok := s.RootModule().Resources[n]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"name":"tf-vol-vigilant-tereshkova","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","volume_type":"scratch","size":20000000000}'
6+
form: {}
7+
headers:
8+
Content-Type:
9+
- application/json
10+
User-Agent:
11+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
12+
terraform/terraform-tests
13+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes
14+
method: POST
15+
response:
16+
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
17+
headers:
18+
Content-Length:
19+
- "450"
20+
Content-Security-Policy:
21+
- default-src 'none'; frame-ancestors 'none'
22+
Content-Type:
23+
- application/json
24+
Date:
25+
- Wed, 06 Sep 2023 11:38:52 GMT
26+
Location:
27+
- https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
28+
Server:
29+
- Scaleway API-Gateway
30+
Strict-Transport-Security:
31+
- max-age=63072000
32+
X-Content-Type-Options:
33+
- nosniff
34+
X-Frame-Options:
35+
- DENY
36+
X-Request-Id:
37+
- 92f58692-32f4-4627-96ba-d3118d71f365
38+
status: 201 Created
39+
code: 201
40+
duration: ""
41+
- request:
42+
body: ""
43+
form: {}
44+
headers:
45+
User-Agent:
46+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
47+
terraform/terraform-tests
48+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
49+
method: GET
50+
response:
51+
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
52+
headers:
53+
Content-Length:
54+
- "450"
55+
Content-Security-Policy:
56+
- default-src 'none'; frame-ancestors 'none'
57+
Content-Type:
58+
- application/json
59+
Date:
60+
- Wed, 06 Sep 2023 11:38:52 GMT
61+
Server:
62+
- Scaleway API-Gateway
63+
Strict-Transport-Security:
64+
- max-age=63072000
65+
X-Content-Type-Options:
66+
- nosniff
67+
X-Frame-Options:
68+
- DENY
69+
X-Request-Id:
70+
- a4820696-3745-4e8d-95a3-dd245ce02757
71+
status: 200 OK
72+
code: 200
73+
duration: ""
74+
- request:
75+
body: ""
76+
form: {}
77+
headers:
78+
User-Agent:
79+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
80+
terraform/terraform-tests
81+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
82+
method: GET
83+
response:
84+
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
85+
headers:
86+
Content-Length:
87+
- "450"
88+
Content-Security-Policy:
89+
- default-src 'none'; frame-ancestors 'none'
90+
Content-Type:
91+
- application/json
92+
Date:
93+
- Wed, 06 Sep 2023 11:38:52 GMT
94+
Server:
95+
- Scaleway API-Gateway
96+
Strict-Transport-Security:
97+
- max-age=63072000
98+
X-Content-Type-Options:
99+
- nosniff
100+
X-Frame-Options:
101+
- DENY
102+
X-Request-Id:
103+
- ca61c348-33ae-443f-8aab-dff22ab1a370
104+
status: 200 OK
105+
code: 200
106+
duration: ""
107+
- request:
108+
body: ""
109+
form: {}
110+
headers:
111+
User-Agent:
112+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
113+
terraform/terraform-tests
114+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
115+
method: GET
116+
response:
117+
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
118+
headers:
119+
Content-Length:
120+
- "450"
121+
Content-Security-Policy:
122+
- default-src 'none'; frame-ancestors 'none'
123+
Content-Type:
124+
- application/json
125+
Date:
126+
- Wed, 06 Sep 2023 11:38:52 GMT
127+
Server:
128+
- Scaleway API-Gateway
129+
Strict-Transport-Security:
130+
- max-age=63072000
131+
X-Content-Type-Options:
132+
- nosniff
133+
X-Frame-Options:
134+
- DENY
135+
X-Request-Id:
136+
- 51902651-be18-41fb-92f9-9af8091910b4
137+
status: 200 OK
138+
code: 200
139+
duration: ""
140+
- request:
141+
body: ""
142+
form: {}
143+
headers:
144+
User-Agent:
145+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
146+
terraform/terraform-tests
147+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
148+
method: GET
149+
response:
150+
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
151+
headers:
152+
Content-Length:
153+
- "450"
154+
Content-Security-Policy:
155+
- default-src 'none'; frame-ancestors 'none'
156+
Content-Type:
157+
- application/json
158+
Date:
159+
- Wed, 06 Sep 2023 11:38:53 GMT
160+
Server:
161+
- Scaleway API-Gateway
162+
Strict-Transport-Security:
163+
- max-age=63072000
164+
X-Content-Type-Options:
165+
- nosniff
166+
X-Frame-Options:
167+
- DENY
168+
X-Request-Id:
169+
- bb45a795-e74f-4832-b20a-5763cd7c6a0c
170+
status: 200 OK
171+
code: 200
172+
duration: ""
173+
- request:
174+
body: ""
175+
form: {}
176+
headers:
177+
User-Agent:
178+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
179+
terraform/terraform-tests
180+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
181+
method: DELETE
182+
response:
183+
body: ""
184+
headers:
185+
Content-Security-Policy:
186+
- default-src 'none'; frame-ancestors 'none'
187+
Date:
188+
- Wed, 06 Sep 2023 11:38:53 GMT
189+
Server:
190+
- Scaleway API-Gateway
191+
Strict-Transport-Security:
192+
- max-age=63072000
193+
X-Content-Type-Options:
194+
- nosniff
195+
X-Frame-Options:
196+
- DENY
197+
X-Request-Id:
198+
- e018bf84-60ce-4c9a-a905-0c7ef04bfdb7
199+
status: 204 No Content
200+
code: 204
201+
duration: ""
202+
- request:
203+
body: ""
204+
form: {}
205+
headers:
206+
User-Agent:
207+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
208+
terraform/terraform-tests
209+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
210+
method: GET
211+
response:
212+
body: '{"message":"resource is not found","resource":"instance_volume","resource_id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","type":"not_found"}'
213+
headers:
214+
Content-Length:
215+
- "143"
216+
Content-Security-Policy:
217+
- default-src 'none'; frame-ancestors 'none'
218+
Content-Type:
219+
- application/json
220+
Date:
221+
- Wed, 06 Sep 2023 11:38:54 GMT
222+
Server:
223+
- Scaleway API-Gateway
224+
Strict-Transport-Security:
225+
- max-age=63072000
226+
X-Content-Type-Options:
227+
- nosniff
228+
X-Frame-Options:
229+
- DENY
230+
X-Request-Id:
231+
- ab666111-d85d-4cde-842c-e87d455285ca
232+
status: 404 Not Found
233+
code: 404
234+
duration: ""

0 commit comments

Comments
 (0)