Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/resources/instance_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ attached to the server. Updates to this field will trigger a stop/start of the s

- `replace_on_type_change` - (Defaults to false) If true, the server will be replaced if `type` is changed. Otherwise, the server will migrate.

- `protected` - (Optional) Set to true to activate server protection option.

- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the server should be created.

- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is associated with.
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/scaleway/terraform-provider-scaleway/v2

go 1.24.0

require (
github.com/aws/aws-sdk-go-v2 v1.36.3
github.com/aws/aws-sdk-go-v2/config v1.29.9
Expand All @@ -25,7 +26,7 @@ require (
github.com/nats-io/jwt/v2 v2.7.3
github.com/nats-io/nats.go v1.38.0
github.com/robfig/cron/v3 v3.0.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250320132958-0f59cae533d0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250407124844-38ab1ca8e81d
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.36.0
gopkg.in/dnaeon/go-vcr.v3 v3.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ 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/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250320132958-0f59cae533d0 h1:aqpUaCWx5ta43b9dZv1bMIvUUJTux9Am+S7RmJbiVN8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250320132958-0f59cae533d0/go.mod h1:792k1RTU+5JeMXm35/e2Wgp71qPH/DmDoZrRc+EFZDk=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250407124844-38ab1ca8e81d h1:EjD1RHPgsTomVw0lKgZu6YHK4ZMSBkSjeFrirnvWBcw=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250407124844-38ab1ca8e81d/go.mod h1:792k1RTU+5JeMXm35/e2Wgp71qPH/DmDoZrRc+EFZDk=
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/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
Expand Down
13 changes: 13 additions & 0 deletions internal/services/instance/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func ResourceServer() *schema.Resource {
Description: "The instanceSDK type of the server", // TODO: link to scaleway pricing in the doc
DiffSuppressFunc: dsf.IgnoreCase,
},
"protected": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, the instance is protected against accidental deletion via the Scaleway API.",
},
"replace_on_type_change": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -384,6 +390,7 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m
SecurityGroup: types.ExpandStringPtr(zonal.ExpandID(d.Get("security_group_id")).ID),
DynamicIPRequired: scw.BoolPtr(d.Get("enable_dynamic_ip").(bool)),
Tags: types.ExpandStrings(d.Get("tags")),
Protected: d.Get("protected").(bool),
}

enableIPv6, ok := d.GetOk("enable_ipv6")
Expand Down Expand Up @@ -619,6 +626,7 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m i
_ = d.Set("enable_dynamic_ip", server.DynamicIPRequired)
_ = d.Set("organization_id", server.Organization)
_ = d.Set("project_id", server.Project)
_ = d.Set("protected", server.Protected)

// Image could be empty in an import context.
image := regional.ExpandID(d.Get("image").(string))
Expand Down Expand Up @@ -824,6 +832,11 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
updateRequest.DynamicIPRequired = scw.BoolPtr(d.Get("enable_dynamic_ip").(bool))
}

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

if d.HasChanges("additional_volume_ids", "root_volume") {
volumes, err := instanceServerVolumesUpdate(ctx, d, api, zone, isStopped)
if err != nil {
Expand Down
Loading
Loading