@@ -192,25 +192,12 @@ func ResourceServer() *schema.Resource {
192192 Optional : true ,
193193 Description : "The additional volumes attached to the server" ,
194194 },
195- "enable_ipv6" : {
196- Type : schema .TypeBool ,
197- Optional : true ,
198- Default : false ,
199- Description : "Determines if IPv6 is enabled for the server" ,
200- Deprecated : "Please use a scaleway_instance_ip with a `routed_ipv6` type" ,
201- },
202195 "private_ip" : {
203196 Type : schema .TypeString ,
204197 Computed : true ,
205198 Description : "The Scaleway internal IP address of the server" ,
206199 Deprecated : "Use ipam_ip datasource instead to fetch your server's IP in your private network." ,
207200 },
208- "public_ip" : {
209- Type : schema .TypeString ,
210- Computed : true ,
211- Description : "The public IPv4 address of the server" ,
212- Deprecated : "Use public_ips instead" ,
213- },
214201 "ip_id" : {
215202 Type : schema .TypeString ,
216203 Optional : true ,
@@ -229,24 +216,6 @@ func ResourceServer() *schema.Resource {
229216 DiffSuppressFunc : dsf .Locality ,
230217 },
231218 },
232- "ipv6_address" : {
233- Type : schema .TypeString ,
234- Computed : true ,
235- Description : "The default public IPv6 address routed to the server." ,
236- Deprecated : "Please use a scaleway_instance_ip with a `routed_ipv6` type" ,
237- },
238- "ipv6_gateway" : {
239- Type : schema .TypeString ,
240- Computed : true ,
241- Description : "The IPv6 gateway address" ,
242- Deprecated : "Please use a scaleway_instance_ip with a `routed_ipv6` type" ,
243- },
244- "ipv6_prefix_length" : {
245- Type : schema .TypeInt ,
246- Computed : true ,
247- Deprecated : "Please use a scaleway_instance_ip with a `routed_ipv6` type" ,
248- Description : "The IPv6 prefix length routed to the server." ,
249- },
250219 "enable_dynamic_ip" : {
251220 Type : schema .TypeBool ,
252221 Optional : true ,
@@ -449,21 +418,14 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m
449418 Protected : d .Get ("protected" ).(bool ),
450419 }
451420
452- enableIPv6 , ok := d .GetOk ("enable_ipv6" )
453- if ok {
454- req .EnableIPv6 = scw .BoolPtr (enableIPv6 .(bool )) //nolint:staticcheck
455- }
456-
457421 if bootType , ok := d .GetOk ("boot_type" ); ok {
458422 bootType := instanceSDK .BootType (bootType .(string ))
459423 req .BootType = & bootType
460424 }
461425
462426 if ipID , ok := d .GetOk ("ip_id" ); ok {
463- req .PublicIP = types .ExpandStringPtr (zonal .ExpandID (ipID ).ID ) //nolint:staticcheck
464- }
465-
466- if ipIDs , ok := d .GetOk ("ip_ids" ); ok {
427+ req .PublicIPs = & []string {zonal .ExpandID (ipID ).ID }
428+ } else if ipIDs , ok := d .GetOk ("ip_ids" ); ok {
467429 req .PublicIPs = types .ExpandSliceIDsPtr (ipIDs )
468430 }
469431
@@ -680,8 +642,6 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m a
680642 }
681643
682644 _ = d .Set ("security_group_id" , zonal .NewID (zone , server .SecurityGroup .ID ).String ())
683- // EnableIPv6 is deprecated
684- _ = d .Set ("enable_ipv6" , server .EnableIPv6 ) //nolint:staticcheck
685645 _ = d .Set ("enable_dynamic_ip" , server .DynamicIPRequired )
686646 _ = d .Set ("organization_id" , server .Organization )
687647 _ = d .Set ("project_id" , server .Project )
@@ -702,31 +662,26 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m a
702662 _ = d .Set ("private_ip" , types .FlattenStringPtr (server .PrivateIP ))
703663 }
704664
705- if _ , hasIPID := d .GetOk ("ip_id" ); server .PublicIP != nil && hasIPID { //nolint:staticcheck
706- if ! server .PublicIP .Dynamic { //nolint:staticcheck
707- _ = d .Set ("ip_id" , zonal .NewID (zone , server .PublicIP .ID ).String ()) //nolint:staticcheck
665+ if ipID , hasIPID := d .GetOk ("ip_id" ); hasIPID {
666+ publicIP := FindIPInList (ipID .(string ), server .PublicIPs )
667+ if publicIP != nil && ! publicIP .Dynamic {
668+ _ = d .Set ("ip_id" , zonal .NewID (zone , publicIP .ID ).String ())
708669 } else {
709670 _ = d .Set ("ip_id" , "" )
710671 }
711672 } else {
712673 _ = d .Set ("ip_id" , "" )
713674 }
714675
715- if server .PublicIP != nil { //nolint:staticcheck
716- _ = d .Set ("public_ip " , server .PublicIP . Address . String ()) //nolint:staticcheck
676+ if len ( server .PublicIPs ) > 0 {
677+ _ = d .Set ("public_ips " , flattenServerPublicIPs ( server .Zone , server . PublicIPs ))
717678 d .SetConnInfo (map [string ]string {
718679 "type" : "ssh" ,
719- "host" : server .PublicIP .Address .String (), //nolint:staticcheck
680+ "host" : server .PublicIPs [ 0 ] .Address .String (),
720681 })
721- } else {
722- _ = d .Set ("public_ip" , "" )
723- d .SetConnInfo (nil )
724- }
725-
726- if len (server .PublicIPs ) > 0 {
727- _ = d .Set ("public_ips" , flattenServerPublicIPs (server .Zone , server .PublicIPs ))
728682 } else {
729683 _ = d .Set ("public_ips" , []any {})
684+ d .SetConnInfo (nil )
730685 }
731686
732687 if _ , hasIPIDs := d .GetOk ("ip_ids" ); hasIPIDs {
@@ -735,22 +690,6 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m a
735690 _ = d .Set ("ip_ids" , []any {})
736691 }
737692
738- if server .IPv6 != nil { //nolint:staticcheck
739- _ = d .Set ("ipv6_address" , server .IPv6 .Address .String ()) //nolint:staticcheck
740- _ = d .Set ("ipv6_gateway" , server .IPv6 .Gateway .String ()) //nolint:staticcheck
741-
742- prefixLength , err := strconv .Atoi (server .IPv6 .Netmask ) //nolint:staticcheck
743- if err != nil {
744- return diag .FromErr (err )
745- }
746-
747- _ = d .Set ("ipv6_prefix_length" , prefixLength )
748- } else {
749- _ = d .Set ("ipv6_address" , nil )
750- _ = d .Set ("ipv6_gateway" , nil )
751- _ = d .Set ("ipv6_prefix_length" , nil )
752- }
753-
754693 if server .AdminPasswordEncryptionSSHKeyID != nil {
755694 _ = d .Set ("admin_password_encryption_ssh_key_id" , server .AdminPasswordEncryptionSSHKeyID )
756695 }
@@ -973,11 +912,6 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
973912 }
974913 }
975914
976- if d .HasChange ("enable_ipv6" ) {
977- serverShouldUpdate = true
978- updateRequest .EnableIPv6 = scw .BoolPtr (d .Get ("enable_ipv6" ).(bool ))
979- }
980-
981915 if d .HasChange ("enable_dynamic_ip" ) {
982916 serverShouldUpdate = true
983917 updateRequest .DynamicIPRequired = scw .BoolPtr (d .Get ("enable_dynamic_ip" ).(bool ))
@@ -1028,10 +962,11 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
1028962
1029963 ipID := zonal .ExpandID (d .Get ("ip_id" )).ID
1030964 // If an IP is already attached, and it's not a dynamic IP we detach it.
1031- if server .PublicIP != nil && ! server .PublicIP .Dynamic { //nolint:staticcheck
965+ publicIP := FindIPInList (ipID , server .PublicIPs )
966+ if publicIP != nil && ! publicIP .Dynamic {
1032967 _ , err = api .UpdateIP (& instanceSDK.UpdateIPRequest {
1033968 Zone : zone ,
1034- IP : server . PublicIP . ID , //nolint:staticcheck
969+ IP : publicIP . ID ,
1035970 Server : & instanceSDK.NullableStringValue {Null : true },
1036971 })
1037972 if err != nil {
0 commit comments