@@ -130,68 +130,70 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
130130 {
131131 Config : `
132132 resource "scaleway_block_volume" "main" {
133- size_in_gb = 50
133+ size_in_gb = 20
134134 iops = 5000
135135 }
136-
137- resource "scaleway_block_snapshot" "main" {
138- volume_id = scaleway_block_volume.main.id
139- }
140- ` ,
141- },
142- {
143- Config : `
144- resource "scaleway_block_volume" "main" {
145- size_in_gb = 50
146- iops = 5000
147- }
148-
149136 resource "scaleway_block_volume" "additional1" {
150- size_in_gb = 50
137+ size_in_gb = 20
138+ iops = 15000
139+ }
140+ resource "scaleway_block_volume" "additional2" {
141+ size_in_gb = 40
151142 iops = 5000
152143 }
153144
154145 resource "scaleway_block_snapshot" "main" {
155146 volume_id = scaleway_block_volume.main.id
156147 }
157-
158148 resource "scaleway_block_snapshot" "additional1" {
159149 volume_id = scaleway_block_volume.additional1.id
160150 }
151+ resource "scaleway_block_snapshot" "additional2" {
152+ volume_id = scaleway_block_volume.additional2.id
153+ }
161154
162155 resource "scaleway_instance_image" "main" {
163156 name = "tf-test-image-external-block-volume"
164157 root_volume_id = scaleway_block_snapshot.main.id
165- additional_volume_ids = [scaleway_block_snapshot.additional1.id]
158+ additional_volume_ids = [
159+ scaleway_block_snapshot.additional1.id,
160+ scaleway_block_snapshot.additional2.id
161+ ]
166162 }
167163 ` ,
168164 Check : resource .ComposeTestCheckFunc (
169165 instancechecks .DoesImageExists (tt , "scaleway_instance_image.main" ),
170166 resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "root_volume_id" , "scaleway_block_snapshot.main" , "id" ),
171167 resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "architecture" , "x86_64" ),
172- resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volume_ids.#" , "1 " ),
168+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volume_ids.#" , "2 " ),
173169 resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volume_ids.0" , "scaleway_block_snapshot.additional1" , "id" ),
170+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volume_ids.1" , "scaleway_block_snapshot.additional2" , "id" ),
174171 ),
175172 },
176173 {
177174 Config : `
178175 resource "scaleway_block_volume" "main" {
179- size_in_gb = 50
176+ size_in_gb = 20
180177 iops = 5000
181178 }
182-
183179 resource "scaleway_block_volume" "additional1" {
184- size_in_gb = 50
180+ size_in_gb = 20
181+ iops = 15000
182+ }
183+ resource "scaleway_block_volume" "additional2" {
184+ size_in_gb = 40
185185 iops = 5000
186186 }
187187
188188 resource "scaleway_block_snapshot" "main" {
189189 volume_id = scaleway_block_volume.main.id
190190 }
191-
192191 resource "scaleway_block_snapshot" "additional1" {
193192 volume_id = scaleway_block_volume.additional1.id
194193 }
194+ resource "scaleway_block_snapshot" "additional2" {
195+ volume_id = scaleway_block_volume.additional2.id
196+ }
195197
196198 resource "scaleway_instance_image" "main" {
197199 name = "tf-test-image-external-block-volume"
@@ -456,61 +458,56 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
456458 {
457459 Config : `
458460 resource "scaleway_instance_server" "server01" {
461+ name = "root-vol0"
459462 image = "ubuntu_focal"
460463 type = "DEV1-S"
461464 root_volume {
462465 size_in_gb = 15
463466 volume_type = "l_ssd"
464467 }
465468 }
466- resource "scaleway_instance_snapshot" "local01" {
467- volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
468- depends_on = [ scaleway_instance_server.server01 ]
469- }
470- ` ,
471- Check : resource .ComposeTestCheckFunc (
472- isServerPresent (tt , "scaleway_instance_server.server01" ),
473- isSnapshotPresent (tt , "scaleway_instance_snapshot.local01" ),
474- ),
475- },
476- {
477- Config : `
478- resource "scaleway_instance_server" "server01" {
469+ resource "scaleway_instance_server" "server02" {
470+ name = "add-vol1"
479471 image = "ubuntu_focal"
480472 type = "DEV1-S"
481473 root_volume {
482- size_in_gb = 15
474+ size_in_gb = 10
483475 volume_type = "l_ssd"
484476 }
485477 }
486- resource "scaleway_instance_server" "server02" {
478+ resource "scaleway_instance_server" "server03" {
479+ name = "add-vol2"
487480 image = "ubuntu_focal"
488481 type = "DEV1-S"
489482 root_volume {
490- size_in_gb = 10
483+ size_in_gb = 20
491484 volume_type = "l_ssd"
492485 }
493486 }
494487
495488 resource "scaleway_instance_snapshot" "local01" {
496489 volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
497- depends_on = [ scaleway_instance_server.server01 ]
498490 }
499491 resource "scaleway_instance_snapshot" "local02" {
500492 volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
501- depends_on = [ scaleway_instance_server.server02 ]
493+ }
494+ resource "scaleway_instance_snapshot" "local03" {
495+ volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
502496 }
503497 ` ,
504498 Check : resource .ComposeTestCheckFunc (
505499 isServerPresent (tt , "scaleway_instance_server.server01" ),
506500 isServerPresent (tt , "scaleway_instance_server.server02" ),
501+ isServerPresent (tt , "scaleway_instance_server.server03" ),
507502 isSnapshotPresent (tt , "scaleway_instance_snapshot.local01" ),
508503 isSnapshotPresent (tt , "scaleway_instance_snapshot.local02" ),
504+ isSnapshotPresent (tt , "scaleway_instance_snapshot.local03" ),
509505 ),
510506 },
511507 {
512508 Config : `
513509 resource "scaleway_instance_server" "server01" {
510+ name = "root-vol0"
514511 image = "ubuntu_focal"
515512 type = "DEV1-S"
516513 root_volume {
@@ -519,42 +516,54 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
519516 }
520517 }
521518 resource "scaleway_instance_server" "server02" {
519+ name = "add-vol1"
522520 image = "ubuntu_focal"
523521 type = "DEV1-S"
524522 root_volume {
525523 size_in_gb = 10
526524 volume_type = "l_ssd"
527525 }
528526 }
527+ resource "scaleway_instance_server" "server03" {
528+ name = "add-vol2"
529+ image = "ubuntu_focal"
530+ type = "DEV1-S"
531+ root_volume {
532+ size_in_gb = 20
533+ volume_type = "l_ssd"
534+ }
535+ }
529536
530537 resource "scaleway_instance_snapshot" "local01" {
531538 volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
532- depends_on = [ scaleway_instance_server.server01 ]
533539 }
534540 resource "scaleway_instance_snapshot" "local02" {
535541 volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
536- depends_on = [ scaleway_instance_server.server02 ]
542+ }
543+ resource "scaleway_instance_snapshot" "local03" {
544+ volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
537545 }
538546
539547 resource "scaleway_instance_image" "main" {
540548 root_volume_id = scaleway_instance_snapshot.local01.id
541- additional_volume_ids = [ scaleway_instance_snapshot.local02.id ]
542- depends_on = [
543- scaleway_instance_snapshot.local01,
544- scaleway_instance_snapshot.local02,
549+ additional_volume_ids = [
550+ scaleway_instance_snapshot.local02.id,
551+ scaleway_instance_snapshot.local03.id
545552 ]
546553 }
547554 ` ,
548555 Check : resource .ComposeTestCheckFunc (
549- isServerPresent (tt , "scaleway_instance_server.server01" ),
550- isServerPresent (tt , "scaleway_instance_server.server02" ),
551556 isSnapshotPresent (tt , "scaleway_instance_snapshot.local01" ),
552557 isSnapshotPresent (tt , "scaleway_instance_snapshot.local02" ),
558+ isSnapshotPresent (tt , "scaleway_instance_snapshot.local03" ),
553559 instancechecks .DoesImageExists (tt , "scaleway_instance_image.main" ),
554560 resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "root_volume_id" , "scaleway_instance_snapshot.local01" , "id" ),
555- resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volumes.0.id" , "scaleway_instance_snapshot.local02" , "id" ),
556561 resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.0.volume_type" , "l_ssd" ),
557562 resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.0.size" , "10000000000" ),
563+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volumes.0.id" , "scaleway_instance_snapshot.local02" , "id" ),
564+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.1.volume_type" , "l_ssd" ),
565+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.1.size" , "20000000000" ),
566+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volumes.1.id" , "scaleway_instance_snapshot.local03" , "id" ),
558567 ),
559568 },
560569 },
0 commit comments