@@ -550,6 +550,147 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
550
550
})
551
551
}
552
552
553
+ func TestAccImage_ServerWithSBSVolume (t * testing.T ) {
554
+ tt := acctest .NewTestTools (t )
555
+ defer tt .Cleanup ()
556
+ resource .ParallelTest (t , resource.TestCase {
557
+ PreCheck : func () { acctest .PreCheck (t ) },
558
+ ProviderFactories : tt .ProviderFactories ,
559
+ CheckDestroy : resource .ComposeTestCheckFunc (
560
+ isImageDestroyed (tt ),
561
+ blocktestfuncs .IsSnapshotDestroyed (tt ),
562
+ blocktestfuncs .IsVolumeDestroyed (tt ),
563
+ instancechecks .IsServerDestroyed (tt ),
564
+ ),
565
+ Steps : []resource.TestStep {
566
+ {
567
+ Config : `
568
+ resource "scaleway_block_volume" "block01" {
569
+ iops = 5000
570
+ size_in_gb = 21
571
+ }
572
+ resource "scaleway_block_snapshot" "block01" {
573
+ volume_id = scaleway_block_volume.block01.id
574
+ depends_on = [ scaleway_block_volume.block01 ]
575
+ }
576
+
577
+ resource "scaleway_instance_server" "server" {
578
+ image = "ubuntu_focal"
579
+ type = "PLAY2-PICO"
580
+ }
581
+ ` ,
582
+ Check : resource .ComposeTestCheckFunc (
583
+ blocktestfuncs .IsVolumePresent (tt , "scaleway_block_volume.block01" ),
584
+ isServerPresent (tt , "scaleway_instance_server.server" ),
585
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.block01" ),
586
+ ),
587
+ },
588
+
589
+ {
590
+ Config : `
591
+ resource "scaleway_block_volume" "block01" {
592
+ iops = 5000
593
+ size_in_gb = 21
594
+ }
595
+ resource "scaleway_block_snapshot" "block01" {
596
+ volume_id = scaleway_block_volume.block01.id
597
+ depends_on = [ scaleway_block_volume.block01 ]
598
+ }
599
+
600
+ resource "scaleway_instance_server" "server" {
601
+ image = "ubuntu_focal"
602
+ type = "PLAY2-PICO"
603
+ }
604
+ resource "scaleway_block_snapshot" "server" {
605
+ volume_id = scaleway_instance_server.server.root_volume.0.volume_id
606
+ depends_on = [ scaleway_instance_server.server ]
607
+ }
608
+
609
+ resource "scaleway_instance_image" "main" {
610
+ root_volume_id = scaleway_block_snapshot.server.id
611
+ additional_volume_ids = [
612
+ scaleway_block_snapshot.block01.id
613
+ ]
614
+ depends_on = [
615
+ scaleway_block_snapshot.block01,
616
+ scaleway_block_snapshot.server,
617
+ ]
618
+ }
619
+ ` ,
620
+ Check : resource .ComposeTestCheckFunc (
621
+ blocktestfuncs .IsVolumePresent (tt , "scaleway_block_volume.block01" ),
622
+ isServerPresent (tt , "scaleway_instance_server.server" ),
623
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.block01" ),
624
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.server" ),
625
+ instancechecks .DoesImageExists (tt , "scaleway_instance_image.main" ),
626
+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "root_volume_id" , "scaleway_block_snapshot.server" , "id" ),
627
+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volumes.0.id" , "scaleway_block_snapshot.block01" , "id" ),
628
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.0.volume_type" , "sbs_snapshot" ),
629
+ resource .TestCheckResourceAttrSet ("scaleway_instance_image.main" , "name" ),
630
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "architecture" , "x86_64" ),
631
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "public" , "false" ),
632
+ ),
633
+ },
634
+ {
635
+ Config : `
636
+ resource "scaleway_block_volume" "block01" {
637
+ iops = 5000
638
+ size_in_gb = 21
639
+ }
640
+ resource "scaleway_block_snapshot" "block01" {
641
+ volume_id = scaleway_block_volume.block01.id
642
+ depends_on = [ scaleway_block_volume.block01 ]
643
+ }
644
+
645
+ resource "scaleway_block_volume" "block02" {
646
+ iops = 15000
647
+ size_in_gb = 22
648
+ }
649
+ resource "scaleway_block_snapshot" "block02" {
650
+ volume_id = scaleway_block_volume.block02.id
651
+ depends_on = [ scaleway_block_volume.block02 ]
652
+ }
653
+
654
+ resource "scaleway_instance_server" "server" {
655
+ image = "ubuntu_focal"
656
+ type = "PLAY2-PICO"
657
+ }
658
+ resource "scaleway_block_snapshot" "server" {
659
+ volume_id = scaleway_instance_server.server.root_volume.0.volume_id
660
+ depends_on = [ scaleway_instance_server.server ]
661
+ }
662
+
663
+ resource "scaleway_instance_image" "main" {
664
+ root_volume_id = scaleway_block_snapshot.server.id
665
+ additional_volume_ids = [
666
+ scaleway_block_snapshot.block02.id,
667
+ ]
668
+ depends_on = [
669
+ scaleway_block_snapshot.block02,
670
+ scaleway_block_snapshot.server,
671
+ ]
672
+ }
673
+ ` ,
674
+ Check : resource .ComposeTestCheckFunc (
675
+ blocktestfuncs .IsVolumePresent (tt , "scaleway_block_volume.block01" ),
676
+ blocktestfuncs .IsVolumePresent (tt , "scaleway_block_volume.block02" ),
677
+ isServerPresent (tt , "scaleway_instance_server.server" ),
678
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.block01" ),
679
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.block02" ),
680
+ blocktestfuncs .IsSnapshotPresent (tt , "scaleway_block_snapshot.server" ),
681
+ instancechecks .DoesImageExists (tt , "scaleway_instance_image.main" ),
682
+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "root_volume_id" , "scaleway_block_snapshot.server" , "id" ),
683
+ resource .TestCheckResourceAttrPair ("scaleway_instance_image.main" , "additional_volumes.0.id" , "scaleway_block_snapshot.block02" , "id" ),
684
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "additional_volumes.0.volume_type" , "sbs_snapshot" ),
685
+ resource .TestCheckResourceAttrSet ("scaleway_instance_image.main" , "name" ),
686
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "architecture" , "x86_64" ),
687
+ resource .TestCheckResourceAttr ("scaleway_instance_image.main" , "public" , "false" ),
688
+ ),
689
+ },
690
+ },
691
+ })
692
+ }
693
+
553
694
func isImageDestroyed (tt * acctest.TestTools ) resource.TestCheckFunc {
554
695
return func (state * terraform.State ) error {
555
696
for _ , rs := range state .RootModule ().Resources {
0 commit comments