Skip to content

Commit 14c7653

Browse files
committed
fix(instance): image: remove MaxItems on additional volumes + fix doc
1 parent 114ccff commit 14c7653

File tree

6 files changed

+11372
-1941
lines changed

6 files changed

+11372
-1941
lines changed

docs/resources/instance_image.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ resource "scaleway_instance_snapshot" "server_snapshot" {
6969
resource "scaleway_instance_image" "image" {
7070
name = "image_with_extra_volumes"
7171
root_volume_id = scaleway_instance_snapshot.server_snapshot.id
72-
additional_volumes = [
72+
additional_volume_ids = [
7373
scaleway_instance_snapshot.volume_snapshot.id
7474
]
7575
}
@@ -83,9 +83,6 @@ The following arguments are supported:
8383
- `name` - (Optional) The name of the image. If not provided it will be randomly generated.
8484
- `architecture` - (Optional, default `x86_64`) The architecture the image is compatible with. Possible values are: `x86_64` or `arm`.
8585
- `additional_volume_ids` - (Optional) List of IDs of the snapshots of the additional volumes to be attached to the image.
86-
87-
-> **Important:** For now it is only possible to have 1 additional_volume.
88-
8986
- `tags` - (Optional) A list of tags to apply to the image.
9087
- `public` - (Optional) Set to `true` if the image is public.
9188
- `zone` - (Defaults to provider `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the image should be created.

internal/services/instance/image.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func ResourceImage() *schema.Resource {
5959
"additional_volume_ids": {
6060
Type: schema.TypeList,
6161
Optional: true,
62-
MaxItems: 1,
6362
Elem: &schema.Schema{
6463
Type: schema.TypeString,
6564
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),

internal/services/instance/image_test.go

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -131,44 +131,41 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
131131
size_in_gb = 50
132132
iops = 5000
133133
}
134-
135-
resource "scaleway_block_snapshot" "main" {
136-
volume_id = scaleway_block_volume.main.id
137-
}
138-
`,
139-
},
140-
{
141-
Config: `
142-
resource "scaleway_block_volume" "main" {
134+
resource "scaleway_block_volume" "additional1" {
143135
size_in_gb = 50
144136
iops = 5000
145137
}
146-
147-
resource "scaleway_block_volume" "additional1" {
138+
resource "scaleway_block_volume" "additional2" {
148139
size_in_gb = 50
149140
iops = 5000
150141
}
151142
152143
resource "scaleway_block_snapshot" "main" {
153144
volume_id = scaleway_block_volume.main.id
154145
}
155-
156146
resource "scaleway_block_snapshot" "additional1" {
157147
volume_id = scaleway_block_volume.additional1.id
158148
}
149+
resource "scaleway_block_snapshot" "additional2" {
150+
volume_id = scaleway_block_volume.additional2.id
151+
}
159152
160153
resource "scaleway_instance_image" "main" {
161154
name = "tf-test-image-external-block-volume"
162155
root_volume_id = scaleway_block_snapshot.main.id
163-
additional_volume_ids = [scaleway_block_snapshot.additional1.id]
156+
additional_volume_ids = [
157+
scaleway_block_snapshot.additional1.id,
158+
scaleway_block_snapshot.additional2.id
159+
]
164160
}
165161
`,
166162
Check: resource.ComposeTestCheckFunc(
167163
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
168164
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_block_snapshot.main", "id"),
169165
resource.TestCheckResourceAttr("scaleway_instance_image.main", "architecture", "x86_64"),
170-
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volume_ids.#", "1"),
166+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volume_ids.#", "2"),
171167
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volume_ids.0", "scaleway_block_snapshot.additional1", "id"),
168+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volume_ids.1", "scaleway_block_snapshot.additional2", "id"),
172169
),
173170
},
174171
{
@@ -177,19 +174,24 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
177174
size_in_gb = 50
178175
iops = 5000
179176
}
180-
181177
resource "scaleway_block_volume" "additional1" {
182178
size_in_gb = 50
183179
iops = 5000
184180
}
181+
resource "scaleway_block_volume" "additional2" {
182+
size_in_gb = 50
183+
iops = 5000
184+
}
185185
186186
resource "scaleway_block_snapshot" "main" {
187187
volume_id = scaleway_block_volume.main.id
188188
}
189-
190189
resource "scaleway_block_snapshot" "additional1" {
191190
volume_id = scaleway_block_volume.additional1.id
192191
}
192+
resource "scaleway_block_snapshot" "additional2" {
193+
volume_id = scaleway_block_volume.additional2.id
194+
}
193195
194196
resource "scaleway_instance_image" "main" {
195197
name = "tf-test-image-external-block-volume"
@@ -458,27 +460,15 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
458460
volume_type = "l_ssd"
459461
}
460462
}
461-
resource "scaleway_instance_snapshot" "local01" {
462-
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
463-
depends_on = [ scaleway_instance_server.server01 ]
464-
}
465-
`,
466-
Check: resource.ComposeTestCheckFunc(
467-
isServerPresent(tt, "scaleway_instance_server.server01"),
468-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
469-
),
470-
},
471-
{
472-
Config: `
473-
resource "scaleway_instance_server" "server01" {
463+
resource "scaleway_instance_server" "server02" {
474464
image = "ubuntu_focal"
475465
type = "DEV1-S"
476466
root_volume {
477-
size_in_gb = 15
467+
size_in_gb = 10
478468
volume_type = "l_ssd"
479469
}
480470
}
481-
resource "scaleway_instance_server" "server02" {
471+
resource "scaleway_instance_server" "server03" {
482472
image = "ubuntu_focal"
483473
type = "DEV1-S"
484474
root_volume {
@@ -489,18 +479,21 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
489479
490480
resource "scaleway_instance_snapshot" "local01" {
491481
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
492-
depends_on = [ scaleway_instance_server.server01 ]
493482
}
494483
resource "scaleway_instance_snapshot" "local02" {
495484
volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
496-
depends_on = [ scaleway_instance_server.server02 ]
485+
}
486+
resource "scaleway_instance_snapshot" "local03" {
487+
volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
497488
}
498489
`,
499490
Check: resource.ComposeTestCheckFunc(
500491
isServerPresent(tt, "scaleway_instance_server.server01"),
501492
isServerPresent(tt, "scaleway_instance_server.server02"),
493+
isServerPresent(tt, "scaleway_instance_server.server03"),
502494
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
503495
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
496+
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
504497
),
505498
},
506499
{
@@ -521,33 +514,43 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
521514
volume_type = "l_ssd"
522515
}
523516
}
517+
resource "scaleway_instance_server" "server03" {
518+
image = "ubuntu_focal"
519+
type = "DEV1-S"
520+
root_volume {
521+
size_in_gb = 10
522+
volume_type = "l_ssd"
523+
}
524+
}
524525
525526
resource "scaleway_instance_snapshot" "local01" {
526527
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
527-
depends_on = [ scaleway_instance_server.server01 ]
528528
}
529529
resource "scaleway_instance_snapshot" "local02" {
530530
volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
531-
depends_on = [ scaleway_instance_server.server02 ]
531+
}
532+
resource "scaleway_instance_snapshot" "local03" {
533+
volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
532534
}
533535
534536
resource "scaleway_instance_image" "main" {
535537
root_volume_id = scaleway_instance_snapshot.local01.id
536-
additional_volume_ids = [ scaleway_instance_snapshot.local02.id ]
537-
depends_on = [
538-
scaleway_instance_snapshot.local01,
539-
scaleway_instance_snapshot.local02,
538+
additional_volume_ids = [
539+
scaleway_instance_snapshot.local02.id,
540+
scaleway_instance_snapshot.local03.id
540541
]
541542
}
542543
`,
543544
Check: resource.ComposeTestCheckFunc(
544-
isServerPresent(tt, "scaleway_instance_server.server01"),
545-
isServerPresent(tt, "scaleway_instance_server.server02"),
546545
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
547546
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
547+
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
548548
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
549549
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.local01", "id"),
550-
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.local02", "id"),
550+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.1.id", "scaleway_instance_snapshot.local02", "id"),
551+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.1.volume_type", "l_ssd"),
552+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.1.size", "10000000000"),
553+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.local03", "id"),
551554
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.volume_type", "l_ssd"),
552555
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.size", "10000000000"),
553556
),

internal/services/instance/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func ResourceServer() *schema.Resource {
289289
Type: schema.TypeMap,
290290
Optional: true,
291291
Computed: true,
292-
Description: "The user data associated with the server", // TODO: document reserved keys (`cloud-init`)
292+
Description: "The user data associated with the server",
293293
Elem: &schema.Schema{
294294
Type: schema.TypeString,
295295
},

0 commit comments

Comments
 (0)