@@ -367,24 +367,23 @@ func resourceScalewayInstanceServerCreate(ctx context.Context, d *schema.Resourc
367
367
rootVolumeName = newRandomName ("vol" )
368
368
}
369
369
370
- var rootVolumeSize scw.Size
370
+ var rootVolumeSize * scw.Size
371
371
if sizeInput == 0 && rootVolumeType == instance .VolumeVolumeTypeLSSD .String () {
372
372
// Compute the rootVolumeSize so it will be valid against the local volume constraints
373
373
// It wouldn't be valid if another local volume is added, but in this case
374
374
// the user would be informed that it does not fulfill the local volume constraints
375
- rootVolumeSize = serverType .VolumesConstraint .MaxSize
376
- } else {
377
- rootVolumeSize = scw .Size (uint64 (sizeInput ) * gb )
375
+ rootVolumeSize = scw . SizePtr ( serverType .VolumesConstraint .MaxSize )
376
+ } else if sizeInput > 0 {
377
+ rootVolumeSize = scw .SizePtr ( scw . Size (uint64 (sizeInput ) * gb ) )
378
378
}
379
379
380
380
req .Volumes ["0" ] = & instance.VolumeServerTemplate {
381
- Name : rootVolumeName ,
382
- ID : rootVolumeID ,
381
+ Name : expandStringPtr ( rootVolumeName ) ,
382
+ ID : expandStringPtr ( rootVolumeID ) ,
383
383
VolumeType : instance .VolumeVolumeType (rootVolumeType ),
384
384
Size : rootVolumeSize ,
385
- Boot : * rootVolumeIsBootVolume ,
385
+ Boot : rootVolumeIsBootVolume ,
386
386
}
387
-
388
387
if raw , ok := d .GetOk ("additional_volume_ids" ); ok {
389
388
for i , volumeID := range raw .([]interface {}) {
390
389
// We have to get the volume to know whether it is a local or a block volume
@@ -396,10 +395,10 @@ func resourceScalewayInstanceServerCreate(ctx context.Context, d *schema.Resourc
396
395
return diag .FromErr (err )
397
396
}
398
397
req .Volumes [strconv .Itoa (i + 1 )] = & instance.VolumeServerTemplate {
399
- ID : vol .Volume .ID ,
400
- Name : vol .Volume .Name ,
398
+ ID : & vol .Volume .ID ,
399
+ Name : & vol .Volume .Name ,
401
400
VolumeType : vol .Volume .VolumeType ,
402
- Size : vol .Volume .Size ,
401
+ Size : & vol .Volume .Size ,
403
402
}
404
403
}
405
404
}
@@ -713,9 +712,9 @@ func resourceScalewayInstanceServerUpdate(ctx context.Context, d *schema.Resourc
713
712
714
713
if raw , hasAdditionalVolumes := d .GetOk ("additional_volume_ids" ); d .HasChanges ("additional_volume_ids" , "root_volume" ) {
715
714
volumes ["0" ] = & instance.VolumeServerTemplate {
716
- ID : expandZonedID (d .Get ("root_volume.0.volume_id" )).ID ,
717
- Name : newRandomName ("vol" ), // name is ignored by the API, any name will work here
718
- Boot : d .Get ("root_volume.0.boot" ).( bool ),
715
+ ID : scw . StringPtr ( expandZonedID (d .Get ("root_volume.0.volume_id" )).ID ) ,
716
+ Name : scw . StringPtr ( newRandomName ("vol" ) ), // name is ignored by the API, any name will work here
717
+ Boot : expandBoolPtr ( d .Get ("root_volume.0.boot" )),
719
718
}
720
719
721
720
if ! hasAdditionalVolumes {
@@ -742,8 +741,8 @@ func resourceScalewayInstanceServerUpdate(ctx context.Context, d *schema.Resourc
742
741
}
743
742
}
744
743
volumes [strconv .Itoa (i + 1 )] = & instance.VolumeServerTemplate {
745
- ID : expandZonedID (volumeID ).ID ,
746
- Name : newRandomName ("vol" ), // name is ignored by the API, any name will work here
744
+ ID : scw . StringPtr ( expandZonedID (volumeID ).ID ) ,
745
+ Name : scw . StringPtr ( newRandomName ("vol" ) ), // name is ignored by the API, any name will work here
747
746
}
748
747
}
749
748
0 commit comments