diff --git a/go.mod b/go.mod index 6153dc66d5..10d6c3cdec 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/nats-io/jwt/v2 v2.7.0 github.com/nats-io/nats.go v1.37.0 github.com/robfig/cron/v3 v3.0.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241016121547-71e46305b9a0 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241018083319-8ca184d21821 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.27.0 gopkg.in/dnaeon/go-vcr.v3 v3.2.0 diff --git a/go.sum b/go.sum index 7c7baedb0a..18d033618b 100644 --- a/go.sum +++ b/go.sum @@ -242,8 +242,8 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241016121547-71e46305b9a0 h1:bykODWS911XOzQZ+WfJ2NmWmFcB0Iuod5+brNIUeNqE= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241016121547-71e46305b9a0/go.mod h1:3jrRJM7638J+P33hKy9MBvfOBxNo8pEGNQQoIv65Ihg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241018083319-8ca184d21821 h1:lUig6xEMWR3vL7jAw0rX8XfCVyrcE11lOfh85TR4jgU= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241018083319-8ca184d21821/go.mod h1:3jrRJM7638J+P33hKy9MBvfOBxNo8pEGNQQoIv65Ihg= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= diff --git a/internal/services/instance/server.go b/internal/services/instance/server.go index 577b10e583..592d09dde8 100644 --- a/internal/services/instance/server.go +++ b/internal/services/instance/server.go @@ -410,7 +410,6 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m Zone: zone, Name: types.ExpandOrGenerateString(d.Get("name"), "srv"), Project: types.ExpandStringPtr(d.Get("project_id")), - Image: imageUUID, CommercialType: commercialType, SecurityGroup: types.ExpandStringPtr(zonal.ExpandID(d.Get("security_group_id")).ID), DynamicIPRequired: scw.BoolPtr(d.Get("enable_dynamic_ip").(bool)), @@ -418,6 +417,10 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m RoutedIPEnabled: types.ExpandBoolPtr(types.GetBool(d, "routed_ip_enabled")), } + if imageUUID != "" { + req.Image = scw.StringPtr(imageUUID) + } + enableIPv6, ok := d.GetOk("enable_ipv6") if ok { req.EnableIPv6 = scw.BoolPtr(enableIPv6.(bool)) //nolint:staticcheck @@ -453,7 +456,7 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m req.Volumes = make(map[string]*instanceSDK.VolumeServerTemplate) rootVolume := d.Get("root_volume.0").(map[string]any) - req.Volumes["0"] = prepareRootVolume(rootVolume, serverType, req.Image).VolumeTemplate() + req.Volumes["0"] = prepareRootVolume(rootVolume, serverType, imageUUID).VolumeTemplate() if raw, ok := d.GetOk("additional_volume_ids"); ok { for i, volumeID := range raw.([]interface{}) { // We have to get the volume to know whether it is a local or a block volume