Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions internal/services/baremetal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ If this behaviour is wanted, please set 'reinstall_on_ssh_key_changes' argument
ValidateFunc: validation.StringLenBetween(0, 255),
Description: "Some description to associate to the server, max 255 characters",
},
"protected": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, the baremetak server is protected against accidental deletion via the Scaleway API.",
},
"tags": {
Type: schema.TypeList,
Elem: &schema.Schema{
Expand Down Expand Up @@ -357,6 +363,7 @@ func ResourceServerCreate(ctx context.Context, d *schema.ResourceData, m any) di
Description: d.Get("description").(string),
OfferID: offerID.ID,
Tags: types.ExpandStrings(d.Get("tags")),
Protected: d.Get("protected").(bool),
}

partitioningSchema := baremetal.Schema{}
Expand Down Expand Up @@ -505,6 +512,7 @@ func ResourceServerRead(ctx context.Context, d *schema.ResourceData, m any) diag
_ = d.Set("ips", flattenIPs(server.IPs))
_ = d.Set("ipv4", flattenIPv4s(server.IPs))
_ = d.Set("ipv6", flattenIPv6s(server.IPs))
_ = d.Set("protected", server.Protected)

if server.Install != nil {
_ = d.Set("os", zonal.NewIDString(server.Zone, os.ID))
Expand Down Expand Up @@ -701,6 +709,11 @@ func ResourceServerUpdate(ctx context.Context, d *schema.ResourceData, m any) di
hasChanged = true
}

if d.HasChange("protected") {
req.Protected = types.ExpandBoolPtr(d.Get("protected").(bool))
hasChanged = true
}

if hasChanged {
_, err = api.UpdateServer(req, scw.WithContext(ctx))
if err != nil {
Expand Down
Loading
Loading