@@ -73,6 +73,12 @@ func ResourceServer() *schema.Resource {
73
73
Description : "The instanceSDK type of the server" , // TODO: link to scaleway pricing in the doc
74
74
DiffSuppressFunc : dsf .IgnoreCase ,
75
75
},
76
+ "protected" : {
77
+ Type : schema .TypeBool ,
78
+ Optional : true ,
79
+ Default : false ,
80
+ Description : "If true, the instance is protected against accidental deletion via the Scaleway API." ,
81
+ },
76
82
"replace_on_type_change" : {
77
83
Type : schema .TypeBool ,
78
84
Optional : true ,
@@ -384,6 +390,7 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m
384
390
SecurityGroup : types .ExpandStringPtr (zonal .ExpandID (d .Get ("security_group_id" )).ID ),
385
391
DynamicIPRequired : scw .BoolPtr (d .Get ("enable_dynamic_ip" ).(bool )),
386
392
Tags : types .ExpandStrings (d .Get ("tags" )),
393
+ Protected : d .Get ("protected" ).(bool ),
387
394
}
388
395
389
396
enableIPv6 , ok := d .GetOk ("enable_ipv6" )
@@ -619,6 +626,7 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m i
619
626
_ = d .Set ("enable_dynamic_ip" , server .DynamicIPRequired )
620
627
_ = d .Set ("organization_id" , server .Organization )
621
628
_ = d .Set ("project_id" , server .Project )
629
+ _ = d .Set ("protected" , server .Protected )
622
630
623
631
// Image could be empty in an import context.
624
632
image := regional .ExpandID (d .Get ("image" ).(string ))
@@ -824,6 +832,11 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
824
832
updateRequest .DynamicIPRequired = scw .BoolPtr (d .Get ("enable_dynamic_ip" ).(bool ))
825
833
}
826
834
835
+ if d .HasChange ("protected" ) {
836
+ serverShouldUpdate = true
837
+ updateRequest .Protected = types .ExpandBoolPtr (d .Get ("protected" ).(bool ))
838
+ }
839
+
827
840
if d .HasChanges ("additional_volume_ids" , "root_volume" ) {
828
841
volumes , err := instanceServerVolumesUpdate (ctx , d , api , zone , isStopped )
829
842
if err != nil {
0 commit comments