@@ -42,7 +42,7 @@ func TestAccAction_InstanceCreateSnapshot_Local(t *testing.T) {
4242 {
4343 Config : fmt .Sprintf (`
4444 resource "scaleway_instance_server" "main" {
45- name = "test-terraform -action-instance-create-snapshot"
45+ name = "test-tf -action-instance-create-snapshot-local "
4646 type = "DEV1-S"
4747 image = "ubuntu_jammy"
4848
@@ -83,7 +83,7 @@ func TestAccAction_InstanceCreateSnapshot_Local(t *testing.T) {
8383 {
8484 Config : fmt .Sprintf (`
8585 resource "scaleway_instance_server" "main" {
86- name = "test-terraform -action-instance-create-snapshot"
86+ name = "test-tf -action-instance-create-snapshot-local "
8787 type = "DEV1-S"
8888 image = "ubuntu_jammy"
8989 tags = [ "add", "tags", "to", "trigger", "update" ]
@@ -142,13 +142,12 @@ func TestAccAction_InstanceCreateSnapshot_Scratch(t *testing.T) {
142142
143143 resource .ParallelTest (t , resource.TestCase {
144144 ProtoV6ProviderFactories : tt .ProviderFactories ,
145- CheckDestroy : resource .ComposeTestCheckFunc (
146- instancechecks .IsVolumeDestroyed (tt ),
147- ),
145+ CheckDestroy : instancechecks .IsServerDestroyed (tt ),
148146 Steps : []resource.TestStep {
149147 {
150148 Config : fmt .Sprintf (`
151149 resource "scaleway_instance_volume" "scratch" {
150+ name = "test-tf-action-instance-create-snapshot-scratch"
152151 type = "%s"
153152 size_in_gb = 50
154153
@@ -172,6 +171,71 @@ func TestAccAction_InstanceCreateSnapshot_Scratch(t *testing.T) {
172171 })
173172}
174173
174+ func TestAccAction_InstanceCreateSnapshot_Zone (t * testing.T ) {
175+ if acctest .IsRunningOpenTofu () {
176+ t .Skip ("Skipping TestAccAction_InstanceCreateSnapshot_Zone because action are not yet supported on OpenTofu" )
177+ }
178+
179+ tt := acctest .NewTestTools (t )
180+ defer tt .Cleanup ()
181+
182+ localVolumeType := instanceSDK .VolumeVolumeTypeLSSD
183+
184+ resource .ParallelTest (t , resource.TestCase {
185+ ProtoV6ProviderFactories : tt .ProviderFactories ,
186+ CheckDestroy : resource .ComposeTestCheckFunc (
187+ instancechecks .IsServerDestroyed (tt ),
188+ destroyUntrackedSnapshots (tt , "data.scaleway_instance_volume.main" ),
189+ ),
190+ Steps : []resource.TestStep {
191+ {
192+ Config : fmt .Sprintf (`
193+ resource "scaleway_instance_server" "main" {
194+ name = "test-tf-action-instance-create-snapshot-zone"
195+ type = "DEV1-S"
196+ image = "ubuntu_jammy"
197+ zone = "fr-par-2"
198+
199+ root_volume {
200+ volume_type = "%s"
201+ size_in_gb = 20
202+ }
203+
204+ lifecycle {
205+ action_trigger {
206+ events = [after_create]
207+ actions = [action.scaleway_instance_create_snapshot.main]
208+ }
209+ }
210+ }
211+
212+ data "scaleway_instance_volume" "main" {
213+ volume_id = scaleway_instance_server.main.root_volume.0.volume_id
214+ zone = "fr-par-2"
215+ }
216+
217+ action "scaleway_instance_create_snapshot" "main" {
218+ config {
219+ volume_id = scaleway_instance_server.main.root_volume.0.volume_id
220+ wait = true
221+ }
222+ }` , localVolumeType ),
223+ },
224+ {
225+ RefreshState : true ,
226+ Check : resource .ComposeTestCheckFunc (
227+ instancechecks .IsVolumePresent (tt , "data.scaleway_instance_volume.main" ),
228+ resource .TestCheckResourceAttr ("scaleway_instance_server.main" , "zone" , "fr-par-2" ),
229+ checkSnapshot (tt , "data.scaleway_instance_volume.main" , snapshotSpecsCheck {
230+ Size : scw .SizePtr (20 * scw .GB ),
231+ Type : & localVolumeType ,
232+ }),
233+ ),
234+ },
235+ },
236+ })
237+ }
238+
175239func snapshotMatchesExpectedSpecs (snapshot instanceSDK.Snapshot , expected snapshotSpecsCheck ) bool {
176240 if expected .Name != nil && * expected .Name != snapshot .Name {
177241 return false
0 commit comments