@@ -148,6 +148,12 @@ If this behaviour is wanted, please set 'reinstall_on_ssh_key_changes' argument
148148 ValidateFunc : validation .StringLenBetween (0 , 255 ),
149149 Description : "Some description to associate to the server, max 255 characters" ,
150150 },
151+ "protected" : {
152+ Type : schema .TypeBool ,
153+ Optional : true ,
154+ Default : false ,
155+ Description : "If true, the baremetak server is protected against accidental deletion via the Scaleway API." ,
156+ },
151157 "tags" : {
152158 Type : schema .TypeList ,
153159 Elem : & schema.Schema {
@@ -357,6 +363,7 @@ func ResourceServerCreate(ctx context.Context, d *schema.ResourceData, m any) di
357363 Description : d .Get ("description" ).(string ),
358364 OfferID : offerID .ID ,
359365 Tags : types .ExpandStrings (d .Get ("tags" )),
366+ Protected : d .Get ("protected" ).(bool ),
360367 }
361368
362369 partitioningSchema := baremetal.Schema {}
@@ -505,6 +512,7 @@ func ResourceServerRead(ctx context.Context, d *schema.ResourceData, m any) diag
505512 _ = d .Set ("ips" , flattenIPs (server .IPs ))
506513 _ = d .Set ("ipv4" , flattenIPv4s (server .IPs ))
507514 _ = d .Set ("ipv6" , flattenIPv6s (server .IPs ))
515+ _ = d .Set ("protected" , server .Protected )
508516
509517 if server .Install != nil {
510518 _ = d .Set ("os" , zonal .NewIDString (server .Zone , os .ID ))
@@ -701,6 +709,11 @@ func ResourceServerUpdate(ctx context.Context, d *schema.ResourceData, m any) di
701709 hasChanged = true
702710 }
703711
712+ if d .HasChange ("protected" ) {
713+ req .Protected = types .ExpandBoolPtr (d .Get ("protected" ).(bool ))
714+ hasChanged = true
715+ }
716+
704717 if hasChanged {
705718 _ , err = api .UpdateServer (req , scw .WithContext (ctx ))
706719 if err != nil {
0 commit comments