From 8432199fdf27e93f9b940d31a3df75dd1030ccb3 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Wed, 3 Dec 2025 09:52:13 +0100 Subject: [PATCH 1/6] feat: add mongodb instance snapshot action --- .../mongodb_instance_snapshot_action.md | 22 + .../action_instance_snapshot_action.go | 202 +++++ .../action_instance_snapshot_action_test.go | 51 ++ ...o-db-instance-snapshot-basic.cassette.yaml | 693 ++++++++++++++++++ provider/framework.go | 2 + .../mongodb_instance_snapshot_action.md.tmpl | 9 + 6 files changed, 979 insertions(+) create mode 100644 docs/actions/mongodb_instance_snapshot_action.md create mode 100644 internal/services/mongodb/action_instance_snapshot_action.go create mode 100644 internal/services/mongodb/action_instance_snapshot_action_test.go create mode 100644 internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml create mode 100644 templates/actions/mongodb_instance_snapshot_action.md.tmpl diff --git a/docs/actions/mongodb_instance_snapshot_action.md b/docs/actions/mongodb_instance_snapshot_action.md new file mode 100644 index 0000000000..c525974ef6 --- /dev/null +++ b/docs/actions/mongodb_instance_snapshot_action.md @@ -0,0 +1,22 @@ +--- +subcategory: "MongoDB" +page_title: "Scaleway: scaleway_mongodb_instance_snapshot_action" +--- + +# scaleway_mongodb_instance_snapshot_action (Action) + + +## Schema + +### Required + +- `expires_at` (String) Expiration date of the snapshot in RFC3339 format (ISO 8601). +- `instance_id` (String) MongoDB instance ID to snapshot. Can be a plain UUID or a regional ID. + +### Optional + +- `name` (String) Name of the snapshot. If not set, a name will be generated. +- `region` (String) Region of the MongoDB instance. If not set, the region is derived from the instance_id when possible or from the provider configuration. +- `wait` (Boolean) Wait for the snapshot to reach a terminal state before returning. + + diff --git a/internal/services/mongodb/action_instance_snapshot_action.go b/internal/services/mongodb/action_instance_snapshot_action.go new file mode 100644 index 0000000000..285feece06 --- /dev/null +++ b/internal/services/mongodb/action_instance_snapshot_action.go @@ -0,0 +1,202 @@ +package mongodb + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/action" + "github.com/hashicorp/terraform-plugin-framework/action/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + mongodb "github.com/scaleway/scaleway-sdk-go/api/mongodb/v1" + "github.com/scaleway/scaleway-sdk-go/scw" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/meta" +) + +var ( + _ action.Action = (*InstanceSnapshotAction)(nil) + _ action.ActionWithConfigure = (*InstanceSnapshotAction)(nil) +) + +// InstanceSnapshotAction creates a snapshot for a MongoDB instance. +type InstanceSnapshotAction struct { + mongodbAPI *mongodb.API +} + +func (a *InstanceSnapshotAction) Configure(_ context.Context, req action.ConfigureRequest, resp *action.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + m, ok := req.ProviderData.(*meta.Meta) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Action Configure Type", + fmt.Sprintf("Expected *meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + a.mongodbAPI = newAPI(m) +} + +func (a *InstanceSnapshotAction) Metadata(_ context.Context, req action.MetadataRequest, resp *action.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_mongodb_instance_snapshot_action" +} + +type InstanceSnapshotActionModel struct { + InstanceID types.String `tfsdk:"instance_id"` + Region types.String `tfsdk:"region"` + Name types.String `tfsdk:"name"` + ExpiresAt types.String `tfsdk:"expires_at"` + Wait types.Bool `tfsdk:"wait"` +} + +// NewInstanceSnapshotAction returns a new MongoDB instance snapshot action. +func NewInstanceSnapshotAction() action.Action { + return &InstanceSnapshotAction{} +} + +func (a *InstanceSnapshotAction) Schema(_ context.Context, _ action.SchemaRequest, resp *action.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "instance_id": schema.StringAttribute{ + Required: true, + Description: "MongoDB instance ID to snapshot. Can be a plain UUID or a regional ID.", + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + }, + }, + "region": schema.StringAttribute{ + Optional: true, + Description: "Region of the MongoDB instance. If not set, the region is derived from the instance_id when possible or from the provider configuration.", + }, + "name": schema.StringAttribute{ + Optional: true, + Description: "Name of the snapshot. If not set, a name will be generated.", + }, + "expires_at": schema.StringAttribute{ + Required: true, + Description: "Expiration date of the snapshot in RFC3339 format (ISO 8601).", + }, + "wait": schema.BoolAttribute{ + Optional: true, + Description: "Wait for the snapshot to reach a terminal state before returning.", + }, + }, + } +} + +func (a *InstanceSnapshotAction) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) { + var data InstanceSnapshotActionModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if a.mongodbAPI == nil { + resp.Diagnostics.AddError( + "Unconfigured mongodbAPI", + "The action was not properly configured. The Scaleway client is missing. "+ + "This is usually a bug in the provider. Please report it to the maintainers.", + ) + + return + } + + if data.InstanceID.IsNull() || data.InstanceID.ValueString() == "" { + resp.Diagnostics.AddError( + "Missing instance_id", + "The instance_id attribute is required to create a MongoDB snapshot.", + ) + + return + } + + instanceID := locality.ExpandID(data.InstanceID.ValueString()) + + var ( + region scw.Region + err error + ) + + if !data.Region.IsNull() && data.Region.ValueString() != "" { + region = scw.Region(data.Region.ValueString()) + } else { + // Try to derive region from the instance_id if it is a regional ID. + if derivedRegion, id, parseErr := regional.ParseID(data.InstanceID.ValueString()); parseErr == nil { + region = derivedRegion + instanceID = id + } + } + + snapshotName := data.Name.ValueString() + if snapshotName == "" { + snapshotName = "tf-mongodb-snapshot" + } + + expirationRaw := data.ExpiresAt.ValueString() + + expirationTime, err := time.Parse(time.RFC3339, expirationRaw) + if err != nil { + resp.Diagnostics.AddError( + "Invalid expires_at value", + fmt.Sprintf("The expires_at attribute must be a valid RFC3339 timestamp. Got %q: %s", expirationRaw, err), + ) + + return + } + + createReq := &mongodb.CreateSnapshotRequest{ + InstanceID: instanceID, + Name: snapshotName, + ExpiresAt: &expirationTime, + } + + if region != "" { + createReq.Region = region + } + + snapshot, err := a.mongodbAPI.CreateSnapshot(createReq, scw.WithContext(ctx)) + if err != nil { + resp.Diagnostics.AddError( + "Error executing MongoDB CreateSnapshot action", + fmt.Sprintf("Failed to create snapshot for instance %s: %s", instanceID, err), + ) + + return + } + + if data.Wait.ValueBool() { + waitRegion := snapshot.Region + if waitRegion == "" && region != "" { + waitRegion = region + } + + if waitRegion == "" { + resp.Diagnostics.AddError( + "Missing region for wait operation", + "Could not determine region to wait for MongoDB snapshot completion.", + ) + + return + } + + _, err = waitForSnapshot(ctx, a.mongodbAPI, waitRegion, instanceID, snapshot.ID, defaultMongodbSnapshotTimeout) + if err != nil { + resp.Diagnostics.AddError( + "Error waiting for MongoDB snapshot completion", + fmt.Sprintf("Snapshot %s for instance %s did not reach a terminal state: %s", snapshot.ID, instanceID, err), + ) + + return + } + } +} diff --git a/internal/services/mongodb/action_instance_snapshot_action_test.go b/internal/services/mongodb/action_instance_snapshot_action_test.go new file mode 100644 index 0000000000..2b84885801 --- /dev/null +++ b/internal/services/mongodb/action_instance_snapshot_action_test.go @@ -0,0 +1,51 @@ +package mongodb_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest" +) + +func TestAccActionMongoDBInstanceSnapshot_Basic(t *testing.T) { + if acctest.IsRunningOpenTofu() { + t.Skip("Skipping TestAccActionMongoDBInstanceSnapshot_Basic because actions are not yet supported on OpenTofu") + } + + tt := acctest.NewTestTools(t) + defer tt.Cleanup() + + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: tt.ProviderFactories, + Steps: []resource.TestStep{ + { + Config: ` + resource "scaleway_mongodb_instance" "main" { + name = "test-mongodb-action-snapshot" + version = "7.0.12" + node_type = "MGDB-PLAY2-NANO" + node_number = 1 + user_name = "my_initial_user" + password = "thiZ_is_v&ry_s3cret" + + lifecycle { + action_trigger { + events = [after_create] + actions = [action.scaleway_mongodb_instance_snapshot_action.main] + } + } + } + + action "scaleway_mongodb_instance_snapshot_action" "main" { + config { + instance_id = scaleway_mongodb_instance.main.id + name = "tf-acc-mongodb-instance-snapshot-action" + expires_at = "2026-11-01T00:00:00Z" + wait = true + } + } + `, + }, + }, + }) +} diff --git a/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml b/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml new file mode 100644 index 0000000000..4017ef9107 --- /dev/null +++ b/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml @@ -0,0 +1,693 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 320 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","name":"test-mongodb-action-snapshot","version":"7.0","tags":null,"node_amount":1,"node_type":"MGDB-PLAY2-NANO","user_name":"my_initial_user","password":"thiZ_is_v\u0026ry_s3cret","volume":{"type":"sbs_5k","size_bytes":5000000000},"endpoints":[{"public_network":{}}]}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 690 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "690" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:29:27 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 40f5458a-e9d1-467c-84d1-fc6e95cc8dfd + status: 200 OK + code: 200 + duration: 694.44325ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 690 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "690" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:29:27 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 8c218b9b-496c-4ad6-b55f-a9ecf4c3bb9a + status: 200 OK + code: 200 + duration: 137.977ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:41 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - af2ff009-b5a0-417d-a2a2-3cccaea5fde1 + status: 200 OK + code: 200 + duration: 137.317917ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:41 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - e9d764d2-0763-49cf-aed0-0b56c23e5082 + status: 200 OK + code: 200 + duration: 56.154875ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b/certificate + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1085 + uncompressed: false + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUp0bVdKc3RYU3NzaDJUSXFRMk9TbW93QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTVRCaVkyUTROakV0TXpWaVlpMDBPR0psTFRobU5HRXROakZpCk0yRTVZakEzTURSaU1CNFhEVEkxTVRJd01qRTBNamt5TjFvWERUTTFNVEV6TURFME1qa3lOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeE1HSmpaRGcyTVMwek5XSmlMVFE0WW1VdE9HWTBZUzAyCk1XSXpZVGxpTURjd05HSXdLakFGQmdNclpYQURJUUNkTGppYXdOL1RRdU94T3JjN0dZaTJNVFd3QnVxeUVWQnYKUm16Q1o4T0xLcU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlJ3MjV2cnFQUWhUVmcvCk9PR0wvS3dWY1VvVjZUQUZCZ01yWlhBRFFRQjU5dW5MaU5ZMklIaXFHVmo3TnFIYjVMRTlzQ3hqTW9GTTFoMVAKQUhVWnJHYldRNHZBeGVGZEZmY3NHazgxSDlPWUM0bGhHOFEvVWZPQnRGZjNTODBOCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + headers: + Content-Length: + - "1085" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:41 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 307c0670-8b30-4ca0-882f-7b295e668300 + status: 200 OK + code: 200 + duration: 29.7125ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 139 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"tf-acc-mongodb-instance-snapshot-action","expires_at":"2026-11-01T00:00:00Z"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 433 + uncompressed: false + body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-02T14:33:41.201545Z","volume_type":"sbs_5k"}' + headers: + Content-Length: + - "433" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:41 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 51330540-a085-454c-972a-32e75cd618ca + status: 200 OK + code: 200 + duration: 282.165542ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/b8bcfe31-d4f8-41ee-a769-35484f3f4ce4 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 433 + uncompressed: false + body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-02T14:33:41.201545Z","volume_type":"sbs_5k"}' + headers: + Content-Length: + - "433" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:41 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - deb09b96-e611-4bec-8366-fcecfd282854 + status: 200 OK + code: 200 + duration: 96.676875ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/b8bcfe31-d4f8-41ee-a769-35484f3f4ce4 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 439 + uncompressed: false + body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":5000000000,"status":"ready","updated_at":"2025-12-02T14:33:42.192458Z","volume_type":"sbs_5k"}' + headers: + Content-Length: + - "439" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:51 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 8aee227b-0de8-4020-8c6c-1d22ac16e45f + status: 200 OK + code: 200 + duration: 251.714417ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:52 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 31efed9f-6e2a-4136-85ba-e954b9ccb047 + status: 200 OK + code: 200 + duration: 97.3115ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b/certificate + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1085 + uncompressed: false + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUp0bVdKc3RYU3NzaDJUSXFRMk9TbW93QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTVRCaVkyUTROakV0TXpWaVlpMDBPR0psTFRobU5HRXROakZpCk0yRTVZakEzTURSaU1CNFhEVEkxTVRJd01qRTBNamt5TjFvWERUTTFNVEV6TURFME1qa3lOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeE1HSmpaRGcyTVMwek5XSmlMVFE0WW1VdE9HWTBZUzAyCk1XSXpZVGxpTURjd05HSXdLakFGQmdNclpYQURJUUNkTGppYXdOL1RRdU94T3JjN0dZaTJNVFd3QnVxeUVWQnYKUm16Q1o4T0xLcU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlJ3MjV2cnFQUWhUVmcvCk9PR0wvS3dWY1VvVjZUQUZCZ01yWlhBRFFRQjU5dW5MaU5ZMklIaXFHVmo3TnFIYjVMRTlzQ3hqTW9GTTFoMVAKQUhVWnJHYldRNHZBeGVGZEZmY3NHazgxSDlPWUM0bGhHOFEvVWZPQnRGZjNTODBOCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + headers: + Content-Length: + - "1085" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:52 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 732742c6-8022-4ae4-ac9e-f0835785f25b + status: 200 OK + code: 200 + duration: 97.396041ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:52 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - cd8703fb-bca6-4c3c-8e4f-fd823f6933da + status: 200 OK + code: 200 + duration: 137.690375ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 569 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":null,"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "569" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:52 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 67060724-6dfb-427c-ae30-5a1908f27851 + status: 200 OK + code: 200 + duration: 315.961917ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 686 + uncompressed: false + body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "686" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:33:52 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 7dbd4af7-44a0-4390-b471-3b80dfe58de1 + status: 200 OK + code: 200 + duration: 30.674875ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 129 + uncompressed: false + body: '{"message":"resource is not found","resource":"instance","resource_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","type":"not_found"}' + headers: + Content-Length: + - "129" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 02 Dec 2025 14:35:54 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fb048cec-e951-46f6-b2b7-10f0341ce115 + status: 404 Not Found + code: 404 + duration: 39.340208ms diff --git a/provider/framework.go b/provider/framework.go index 03dedf8db3..6acf9bceb8 100644 --- a/provider/framework.go +++ b/provider/framework.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/scaleway/terraform-provider-scaleway/v2/internal/meta" "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/instance" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/mongodb" ) var ( @@ -138,6 +139,7 @@ func (p *ScalewayProvider) Actions(_ context.Context) []func() action.Action { var res []func() action.Action res = append(res, instance.NewServerAction) + res = append(res, mongodb.NewInstanceSnapshotAction) return res } diff --git a/templates/actions/mongodb_instance_snapshot_action.md.tmpl b/templates/actions/mongodb_instance_snapshot_action.md.tmpl new file mode 100644 index 0000000000..7ecfbc0711 --- /dev/null +++ b/templates/actions/mongodb_instance_snapshot_action.md.tmpl @@ -0,0 +1,9 @@ +{{- /*gotype: github.com/hashicorp/terraform-plugin-docs/internal/provider.ActionTemplateType */ -}} +--- +subcategory: "MongoDB" +page_title: "Scaleway: scaleway_mongodb_instance_snapshot_action" +--- + +# scaleway_mongodb_instance_snapshot_action (Action) + +{{ .SchemaMarkdown }} From 47aa4d35d5820e94beac62c74c4a3e3105535589 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Thu, 4 Dec 2025 14:49:56 +0100 Subject: [PATCH 2/6] feat: make expires_at optional in MongoDB snapshot action and add audit trail verification --- .../action_instance_snapshot_action.go | 27 +++++---- .../action_instance_snapshot_action_test.go | 58 +++++++++++++++++++ 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/internal/services/mongodb/action_instance_snapshot_action.go b/internal/services/mongodb/action_instance_snapshot_action.go index 285feece06..44f6ad77d5 100644 --- a/internal/services/mongodb/action_instance_snapshot_action.go +++ b/internal/services/mongodb/action_instance_snapshot_action.go @@ -81,8 +81,8 @@ func (a *InstanceSnapshotAction) Schema(_ context.Context, _ action.SchemaReques Description: "Name of the snapshot. If not set, a name will be generated.", }, "expires_at": schema.StringAttribute{ - Required: true, - Description: "Expiration date of the snapshot in RFC3339 format (ISO 8601).", + Optional: true, + Description: "Expiration date of the snapshot in RFC3339 format (ISO 8601). If not set, the snapshot will not expire.", }, "wait": schema.BoolAttribute{ Optional: true, @@ -142,22 +142,27 @@ func (a *InstanceSnapshotAction) Invoke(ctx context.Context, req action.InvokeRe snapshotName = "tf-mongodb-snapshot" } - expirationRaw := data.ExpiresAt.ValueString() + var expirationTime *time.Time + if !data.ExpiresAt.IsNull() && data.ExpiresAt.ValueString() != "" { + expirationRaw := data.ExpiresAt.ValueString() - expirationTime, err := time.Parse(time.RFC3339, expirationRaw) - if err != nil { - resp.Diagnostics.AddError( - "Invalid expires_at value", - fmt.Sprintf("The expires_at attribute must be a valid RFC3339 timestamp. Got %q: %s", expirationRaw, err), - ) + parsedTime, err := time.Parse(time.RFC3339, expirationRaw) + if err != nil { + resp.Diagnostics.AddError( + "Invalid expires_at value", + fmt.Sprintf("The expires_at attribute must be a valid RFC3339 timestamp. Got %q: %s", expirationRaw, err), + ) - return + return + } + + expirationTime = &parsedTime } createReq := &mongodb.CreateSnapshotRequest{ InstanceID: instanceID, Name: snapshotName, - ExpiresAt: &expirationTime, + ExpiresAt: expirationTime, } if region != "" { diff --git a/internal/services/mongodb/action_instance_snapshot_action_test.go b/internal/services/mongodb/action_instance_snapshot_action_test.go index 2b84885801..39183e84e5 100644 --- a/internal/services/mongodb/action_instance_snapshot_action_test.go +++ b/internal/services/mongodb/action_instance_snapshot_action_test.go @@ -1,9 +1,12 @@ package mongodb_test import ( + "errors" + "strings" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest" ) @@ -46,6 +49,61 @@ func TestAccActionMongoDBInstanceSnapshot_Basic(t *testing.T) { } `, }, + { + Config: ` + resource "scaleway_mongodb_instance" "main" { + name = "test-mongodb-action-snapshot" + version = "7.0.12" + node_type = "MGDB-PLAY2-NANO" + node_number = 1 + user_name = "my_initial_user" + password = "thiZ_is_v&ry_s3cret" + + lifecycle { + action_trigger { + events = [after_create] + actions = [action.scaleway_mongodb_instance_snapshot_action.main] + } + } + } + + action "scaleway_mongodb_instance_snapshot_action" "main" { + config { + instance_id = scaleway_mongodb_instance.main.id + name = "tf-acc-mongodb-instance-snapshot-action" + expires_at = "2026-11-01T00:00:00Z" + wait = true + } + } + + data "scaleway_audit_trail_event" "mongodb" { + resource_type = "mongodb_instance" + resource_id = scaleway_mongodb_instance.main.id + method_name = "CreateSnapshot" + } + `, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.scaleway_audit_trail_event.mongodb", "events.#"), + func(state *terraform.State) error { + rs, ok := state.RootModule().Resources["data.scaleway_audit_trail_event.mongodb"] + if !ok { + return errors.New("not found: data.scaleway_audit_trail_event.mongodb") + } + + for key, value := range rs.Primary.Attributes { + if !strings.Contains(key, "request_body") { + continue + } + + if strings.Contains(value, "tf-acc-mongodb-instance-snapshot-action") { + return nil + } + } + + return errors.New("did not find the CreateSnapshot event") + }, + ), + }, }, }) } From 08ad79a8487c1476bc3a66f6abc3a1ba0dd332e3 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Thu, 4 Dec 2025 15:01:44 +0100 Subject: [PATCH 3/6] feat: replace audit trail verification with direct snapshot check for MongoDB action --- .../action_instance_snapshot_action_test.go | 66 +++++++++++-------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/internal/services/mongodb/action_instance_snapshot_action_test.go b/internal/services/mongodb/action_instance_snapshot_action_test.go index 39183e84e5..62db212737 100644 --- a/internal/services/mongodb/action_instance_snapshot_action_test.go +++ b/internal/services/mongodb/action_instance_snapshot_action_test.go @@ -1,13 +1,16 @@ package mongodb_test import ( - "errors" - "strings" + "context" + "fmt" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" + mongodbSDK "github.com/scaleway/scaleway-sdk-go/api/mongodb/v1" + "github.com/scaleway/scaleway-sdk-go/scw" "github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional" ) func TestAccActionMongoDBInstanceSnapshot_Basic(t *testing.T) { @@ -75,35 +78,44 @@ func TestAccActionMongoDBInstanceSnapshot_Basic(t *testing.T) { wait = true } } - - data "scaleway_audit_trail_event" "mongodb" { - resource_type = "mongodb_instance" - resource_id = scaleway_mongodb_instance.main.id - method_name = "CreateSnapshot" - } `, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.scaleway_audit_trail_event.mongodb", "events.#"), - func(state *terraform.State) error { - rs, ok := state.RootModule().Resources["data.scaleway_audit_trail_event.mongodb"] - if !ok { - return errors.New("not found: data.scaleway_audit_trail_event.mongodb") - } - - for key, value := range rs.Primary.Attributes { - if !strings.Contains(key, "request_body") { - continue - } - - if strings.Contains(value, "tf-acc-mongodb-instance-snapshot-action") { - return nil - } - } - - return errors.New("did not find the CreateSnapshot event") - }, + isSnapshotCreated(tt, "scaleway_mongodb_instance.main", "tf-acc-mongodb-instance-snapshot-action"), ), }, }, }) } + +func isSnapshotCreated(tt *acctest.TestTools, instanceResourceName, snapshotName string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs, ok := state.RootModule().Resources[instanceResourceName] + if !ok { + return fmt.Errorf("resource not found: %s", instanceResourceName) + } + + instanceID := rs.Primary.ID + region, id, err := regional.ParseID(instanceID) + if err != nil { + return fmt.Errorf("failed to parse instance ID: %w", err) + } + + api := mongodbSDK.NewAPI(tt.Meta.ScwClient()) + + snapshots, err := api.ListSnapshots(&mongodbSDK.ListSnapshotsRequest{ + Region: region, + InstanceID: &id, + }, scw.WithAllPages(), scw.WithContext(context.Background())) + if err != nil { + return fmt.Errorf("failed to list snapshots: %w", err) + } + + for _, snapshot := range snapshots.Snapshots { + if snapshot.Name == snapshotName { + return nil + } + } + + return fmt.Errorf("snapshot with name %q not found for instance %s", snapshotName, instanceID) + } +} From 22190b1ec3cd4dcb5506195080dd19de03716439 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Thu, 4 Dec 2025 15:12:26 +0100 Subject: [PATCH 4/6] feat: compress MongoDB snapshot action test cassette --- ...o-db-instance-snapshot-basic.cassette.yaml | 415 ++++++++++++++---- 1 file changed, 330 insertions(+), 85 deletions(-) diff --git a/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml b/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml index 4017ef9107..6ddab88eb2 100644 --- a/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml +++ b/internal/services/mongodb/testdata/action-mongo-db-instance-snapshot-basic.cassette.yaml @@ -29,7 +29,7 @@ interactions: trailer: {} content_length: 690 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "690" @@ -38,9 +38,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:29:27 GMT + - Thu, 04 Dec 2025 14:05:37 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -48,10 +48,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 40f5458a-e9d1-467c-84d1-fc6e95cc8dfd + - df1db288-64f9-4565-8989-a448c6639128 status: 200 OK code: 200 - duration: 694.44325ms + duration: 616.770667ms - id: 1 request: proto: HTTP/1.1 @@ -68,7 +68,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -78,7 +78,7 @@ interactions: trailer: {} content_length: 690 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"provisioning","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "690" @@ -87,9 +87,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:29:27 GMT + - Thu, 04 Dec 2025 14:05:37 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -97,10 +97,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 8c218b9b-496c-4ad6-b55f-a9ecf4c3bb9a + - aeb6a70d-6620-4799-8796-0398361592bf status: 200 OK code: 200 - duration: 137.977ms + duration: 100.707083ms - id: 2 request: proto: HTTP/1.1 @@ -117,7 +117,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -127,7 +127,7 @@ interactions: trailer: {} content_length: 683 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "683" @@ -136,9 +136,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:41 GMT + - Thu, 04 Dec 2025 14:10:11 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -146,10 +146,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - af2ff009-b5a0-417d-a2a2-3cccaea5fde1 + - cc09ca3a-5662-41f8-acad-d1f92dc5add6 status: 200 OK code: 200 - duration: 137.317917ms + duration: 122.751ms - id: 3 request: proto: HTTP/1.1 @@ -166,7 +166,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -176,7 +176,7 @@ interactions: trailer: {} content_length: 683 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "683" @@ -185,9 +185,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:41 GMT + - Thu, 04 Dec 2025 14:10:12 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -195,10 +195,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - e9d764d2-0763-49cf-aed0-0b56c23e5082 + - deed10bd-2942-4830-93d0-2e16f524a022 status: 200 OK code: 200 - duration: 56.154875ms + duration: 131.142166ms - id: 4 request: proto: HTTP/1.1 @@ -215,7 +215,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b/certificate + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574/certificate method: GET response: proto: HTTP/2.0 @@ -225,7 +225,7 @@ interactions: trailer: {} content_length: 1085 uncompressed: false - body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUp0bVdKc3RYU3NzaDJUSXFRMk9TbW93QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTVRCaVkyUTROakV0TXpWaVlpMDBPR0psTFRobU5HRXROakZpCk0yRTVZakEzTURSaU1CNFhEVEkxTVRJd01qRTBNamt5TjFvWERUTTFNVEV6TURFME1qa3lOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeE1HSmpaRGcyTVMwek5XSmlMVFE0WW1VdE9HWTBZUzAyCk1XSXpZVGxpTURjd05HSXdLakFGQmdNclpYQURJUUNkTGppYXdOL1RRdU94T3JjN0dZaTJNVFd3QnVxeUVWQnYKUm16Q1o4T0xLcU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlJ3MjV2cnFQUWhUVmcvCk9PR0wvS3dWY1VvVjZUQUZCZ01yWlhBRFFRQjU5dW5MaU5ZMklIaXFHVmo3TnFIYjVMRTlzQ3hqTW9GTTFoMVAKQUhVWnJHYldRNHZBeGVGZEZmY3NHazgxSDlPWUM0bGhHOFEvVWZPQnRGZjNTODBOCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUxTRHVoZjFsZkI0M2NzK1htSmFsREV3QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTW1Jd01HUTFaak10TXpKall5MDBNemN6TFRsbE1Ua3RaRGd5Ck16UTVNMlEzTlRjME1CNFhEVEkxTVRJd05ERTBNRFV6TjFvWERUTTFNVEl3TWpFME1EVXpOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeVlqQXdaRFZtTXkwek1tTmpMVFF6TnpNdE9XVXhPUzFrCk9ESXpORGt6WkRjMU56UXdLakFGQmdNclpYQURJUUFmZm9WdG9HdGs4Qy9VQnVzZmhjR2s3d0FJQ1VJcVoxYi8KTFFDNkwzTDhWYU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlIwalFncTVNc1lSQzAvCnJPVmNNeHA1dGladmVqQUZCZ01yWlhBRFFRQlRDK0VJME0rR2gyai9uTE0weUhOSTZ4UE93Z0VpQVRzTU1XQlgKa29XVE9NLzJkREo5emhNUlQvQUdXUUVIRXhSTjk2bkJXUm4xQXVLVXZvd3hFY1lGCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' headers: Content-Length: - "1085" @@ -234,9 +234,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:41 GMT + - Thu, 04 Dec 2025 14:10:12 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -244,10 +244,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 307c0670-8b30-4ca0-882f-7b295e668300 + - 93dc1689-fbe6-4531-bed7-d2501c66ccc7 status: 200 OK code: 200 - duration: 29.7125ms + duration: 23.310084ms - id: 5 request: proto: HTTP/1.1 @@ -259,7 +259,7 @@ interactions: host: api.scaleway.com remote_addr: "" request_uri: "" - body: '{"instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"tf-acc-mongodb-instance-snapshot-action","expires_at":"2026-11-01T00:00:00Z"}' + body: '{"instance_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"tf-acc-mongodb-instance-snapshot-action","expires_at":"2026-11-01T00:00:00Z"}' form: {} headers: Content-Type: @@ -276,7 +276,7 @@ interactions: trailer: {} content_length: 433 uncompressed: false - body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-02T14:33:41.201545Z","volume_type":"sbs_5k"}' + body: '{"created_at":"2025-12-04T14:10:12.069846Z","expires_at":"2026-11-01T00:00:00Z","id":"2b570138-1139-4d6b-9ebf-a8e4bed1d58e","instance_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-04T14:10:12.069846Z","volume_type":"sbs_5k"}' headers: Content-Length: - "433" @@ -285,9 +285,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:41 GMT + - Thu, 04 Dec 2025 14:10:12 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -295,10 +295,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 51330540-a085-454c-972a-32e75cd618ca + - f42caaa6-62e7-4c66-8d49-d0e693b8941b status: 200 OK code: 200 - duration: 282.165542ms + duration: 245.793625ms - id: 6 request: proto: HTTP/1.1 @@ -315,7 +315,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/b8bcfe31-d4f8-41ee-a769-35484f3f4ce4 + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/2b570138-1139-4d6b-9ebf-a8e4bed1d58e method: GET response: proto: HTTP/2.0 @@ -325,7 +325,7 @@ interactions: trailer: {} content_length: 433 uncompressed: false - body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-02T14:33:41.201545Z","volume_type":"sbs_5k"}' + body: '{"created_at":"2025-12-04T14:10:12.069846Z","expires_at":"2026-11-01T00:00:00Z","id":"2b570138-1139-4d6b-9ebf-a8e4bed1d58e","instance_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":0,"status":"creating","updated_at":"2025-12-04T14:10:12.069846Z","volume_type":"sbs_5k"}' headers: Content-Length: - "433" @@ -334,9 +334,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:41 GMT + - Thu, 04 Dec 2025 14:10:12 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -344,10 +344,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - deb09b96-e611-4bec-8366-fcecfd282854 + - c7a04bf6-2ff3-44b3-9901-11cb28c2f2e6 status: 200 OK code: 200 - duration: 96.676875ms + duration: 188.463542ms - id: 7 request: proto: HTTP/1.1 @@ -364,7 +364,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/b8bcfe31-d4f8-41ee-a769-35484f3f4ce4 + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots/2b570138-1139-4d6b-9ebf-a8e4bed1d58e method: GET response: proto: HTTP/2.0 @@ -374,7 +374,7 @@ interactions: trailer: {} content_length: 439 uncompressed: false - body: '{"created_at":"2025-12-02T14:33:41.201545Z","expires_at":"2026-11-01T00:00:00Z","id":"b8bcfe31-d4f8-41ee-a769-35484f3f4ce4","instance_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":5000000000,"status":"ready","updated_at":"2025-12-02T14:33:42.192458Z","volume_type":"sbs_5k"}' + body: '{"created_at":"2025-12-04T14:10:12.069846Z","expires_at":"2026-11-01T00:00:00Z","id":"2b570138-1139-4d6b-9ebf-a8e4bed1d58e","instance_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":5000000000,"status":"ready","updated_at":"2025-12-04T14:10:12.863314Z","volume_type":"sbs_5k"}' headers: Content-Length: - "439" @@ -383,9 +383,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:51 GMT + - Thu, 04 Dec 2025 14:10:22 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -393,10 +393,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 8aee227b-0de8-4020-8c6c-1d22ac16e45f + - 586cc8ce-ae3a-4acb-a5e7-2f9b7ad9febe status: 200 OK code: 200 - duration: 251.714417ms + duration: 106.351541ms - id: 8 request: proto: HTTP/1.1 @@ -413,7 +413,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -423,7 +423,7 @@ interactions: trailer: {} content_length: 683 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "683" @@ -432,9 +432,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:52 GMT + - Thu, 04 Dec 2025 14:10:23 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -442,10 +442,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 31efed9f-6e2a-4136-85ba-e954b9ccb047 + - d6f01652-f3cb-4f87-b714-01d9f479fa22 status: 200 OK code: 200 - duration: 97.3115ms + duration: 97.513292ms - id: 9 request: proto: HTTP/1.1 @@ -462,7 +462,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b/certificate + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574/certificate method: GET response: proto: HTTP/2.0 @@ -472,7 +472,7 @@ interactions: trailer: {} content_length: 1085 uncompressed: false - body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUp0bVdKc3RYU3NzaDJUSXFRMk9TbW93QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTVRCaVkyUTROakV0TXpWaVlpMDBPR0psTFRobU5HRXROakZpCk0yRTVZakEzTURSaU1CNFhEVEkxTVRJd01qRTBNamt5TjFvWERUTTFNVEV6TURFME1qa3lOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeE1HSmpaRGcyTVMwek5XSmlMVFE0WW1VdE9HWTBZUzAyCk1XSXpZVGxpTURjd05HSXdLakFGQmdNclpYQURJUUNkTGppYXdOL1RRdU94T3JjN0dZaTJNVFd3QnVxeUVWQnYKUm16Q1o4T0xLcU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlJ3MjV2cnFQUWhUVmcvCk9PR0wvS3dWY1VvVjZUQUZCZ01yWlhBRFFRQjU5dW5MaU5ZMklIaXFHVmo3TnFIYjVMRTlzQ3hqTW9GTTFoMVAKQUhVWnJHYldRNHZBeGVGZEZmY3NHazgxSDlPWUM0bGhHOFEvVWZPQnRGZjNTODBOCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUxTRHVoZjFsZkI0M2NzK1htSmFsREV3QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTW1Jd01HUTFaak10TXpKall5MDBNemN6TFRsbE1Ua3RaRGd5Ck16UTVNMlEzTlRjME1CNFhEVEkxTVRJd05ERTBNRFV6TjFvWERUTTFNVEl3TWpFME1EVXpOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeVlqQXdaRFZtTXkwek1tTmpMVFF6TnpNdE9XVXhPUzFrCk9ESXpORGt6WkRjMU56UXdLakFGQmdNclpYQURJUUFmZm9WdG9HdGs4Qy9VQnVzZmhjR2s3d0FJQ1VJcVoxYi8KTFFDNkwzTDhWYU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlIwalFncTVNc1lSQzAvCnJPVmNNeHA1dGladmVqQUZCZ01yWlhBRFFRQlRDK0VJME0rR2gyai9uTE0weUhOSTZ4UE93Z0VpQVRzTU1XQlgKa29XVE9NLzJkREo5emhNUlQvQUdXUUVIRXhSTjk2bkJXUm4xQXVLVXZvd3hFY1lGCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' headers: Content-Length: - "1085" @@ -481,9 +481,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:52 GMT + - Thu, 04 Dec 2025 14:10:23 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -491,10 +491,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 732742c6-8022-4ae4-ac9e-f0835785f25b + - cffa3c3c-07c2-45ee-8ca3-7cccb5772b4b status: 200 OK code: 200 - duration: 97.396041ms + duration: 93.143125ms - id: 10 request: proto: HTTP/1.1 @@ -511,7 +511,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -521,7 +521,7 @@ interactions: trailer: {} content_length: 683 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "683" @@ -530,9 +530,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:52 GMT + - Thu, 04 Dec 2025 14:10:23 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -540,10 +540,10 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - cd8703fb-bca6-4c3c-8e4f-fd823f6933da + - 161eb47f-58ea-47f6-afff-ac39368bee60 status: 200 OK code: 200 - duration: 137.690375ms + duration: 118.143458ms - id: 11 request: proto: HTTP/1.1 @@ -560,7 +560,252 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574/certificate + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1085 + uncompressed: false + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUxTRHVoZjFsZkI0M2NzK1htSmFsREV3QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTW1Jd01HUTFaak10TXpKall5MDBNemN6TFRsbE1Ua3RaRGd5Ck16UTVNMlEzTlRjME1CNFhEVEkxTVRJd05ERTBNRFV6TjFvWERUTTFNVEl3TWpFME1EVXpOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeVlqQXdaRFZtTXkwek1tTmpMVFF6TnpNdE9XVXhPUzFrCk9ESXpORGt6WkRjMU56UXdLakFGQmdNclpYQURJUUFmZm9WdG9HdGs4Qy9VQnVzZmhjR2s3d0FJQ1VJcVoxYi8KTFFDNkwzTDhWYU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlIwalFncTVNc1lSQzAvCnJPVmNNeHA1dGladmVqQUZCZ01yWlhBRFFRQlRDK0VJME0rR2gyai9uTE0weUhOSTZ4UE93Z0VpQVRzTU1XQlgKa29XVE9NLzJkREo5emhNUlQvQUdXUUVIRXhSTjk2bkJXUm4xQXVLVXZvd3hFY1lGCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + headers: + Content-Length: + - "1085" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 04 Dec 2025 14:10:23 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 0ec1bcbc-b429-4b48-924a-045b1578a078 + status: 200 OK + code: 200 + duration: 28.324667ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/snapshots?instance_id=2b00d5f3-32cc-4373-9e19-d823493d7574&order_by=created_at_asc&page=1 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 472 + uncompressed: false + body: '{"snapshots":[{"created_at":"2025-12-04T14:10:12.069846Z","expires_at":"2026-11-01T00:00:00Z","id":"2b570138-1139-4d6b-9ebf-a8e4bed1d58e","instance_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","instance_name":"test-mongodb-action-snapshot","name":"tf-acc-mongodb-instance-snapshot-action","node_type":"mgdb-play2-nano","region":"fr-par","size_bytes":5000000000,"status":"ready","updated_at":"2025-12-04T14:10:12.863314Z","volume_type":"sbs_5k"}],"total_count":1}' + headers: + Content-Length: + - "472" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 04 Dec 2025 14:10:23 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fcce882f-f797-448d-aa15-40f8123e09f0 + status: 200 OK + code: 200 + duration: 118.565958ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 04 Dec 2025 14:10:23 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3802c6bc-4810-4511-a802-5f0de425ad93 + status: 200 OK + code: 200 + duration: 28.446167ms + - id: 14 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574/certificate + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1085 + uncompressed: false + body: '{"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNBRENDQWJLZ0F3SUJBZ0lSQUxTRHVoZjFsZkI0M2NzK1htSmFsREV3QlFZREsyVndNSEF4Q3pBSkJnTlYKQkFZVEFrWlNNUTR3REFZRFZRUUhFd1ZRWVhKcGN6RVpNQmNHQTFVRUNoTVFVMk5oYkdWM1lYa2dUVzl1WjI5RQpRakUyTURRR0ExVUVDeE10U1c1emRHRnVZMlVnTW1Jd01HUTFaak10TXpKall5MDBNemN6TFRsbE1Ua3RaRGd5Ck16UTVNMlEzTlRjME1CNFhEVEkxTVRJd05ERTBNRFV6TjFvWERUTTFNVEl3TWpFME1EVXpOMW93Y0RFTE1Ba0cKQTFVRUJoTUNSbEl4RGpBTUJnTlZCQWNUQlZCaGNtbHpNUmt3RndZRFZRUUtFeEJUWTJGc1pYZGhlU0JOYjI1bgpiMFJDTVRZd05BWURWUVFMRXkxSmJuTjBZVzVqWlNBeVlqQXdaRFZtTXkwek1tTmpMVFF6TnpNdE9XVXhPUzFrCk9ESXpORGt6WkRjMU56UXdLakFGQmdNclpYQURJUUFmZm9WdG9HdGs4Qy9VQnVzZmhjR2s3d0FJQ1VJcVoxYi8KTFFDNkwzTDhWYU5oTUY4d0RnWURWUjBQQVFIL0JBUURBZ0lFTUIwR0ExVWRKUVFXTUJRR0NDc0dBUVVGQndNQwpCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlIwalFncTVNc1lSQzAvCnJPVmNNeHA1dGladmVqQUZCZ01yWlhBRFFRQlRDK0VJME0rR2gyai9uTE0weUhOSTZ4UE93Z0VpQVRzTU1XQlgKa29XVE9NLzJkREo5emhNUlQvQUdXUUVIRXhSTjk2bkJXUm4xQXVLVXZvd3hFY1lGCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K","content_type":"application/x-pem-file","name":"ssl_certificate"}' + headers: + Content-Length: + - "1085" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 04 Dec 2025 14:10:24 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c2e3991e-028f-48eb-afe5-abb5cce60556 + status: 200 OK + code: 200 + duration: 90.469625ms + - id: 15 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 683 + uncompressed: false + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"ready","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + headers: + Content-Length: + - "683" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 04 Dec 2025 14:10:24 GMT + Server: + - Scaleway API Gateway (fr-par-2;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 833a3c11-a2d0-46b3-9df7-a8da66da9f03 + status: 200 OK + code: 200 + duration: 30.802875ms + - id: 16 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: DELETE response: proto: HTTP/2.0 @@ -570,7 +815,7 @@ interactions: trailer: {} content_length: 569 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":null,"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":null,"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "569" @@ -579,9 +824,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:52 GMT + - Thu, 04 Dec 2025 14:10:24 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -589,11 +834,11 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 67060724-6dfb-427c-ae30-5a1908f27851 + - 8d8a1ee6-93c6-4ae6-bc93-21bdc39913cb status: 200 OK code: 200 - duration: 315.961917ms - - id: 12 + duration: 177.707375ms + - id: 17 request: proto: HTTP/1.1 proto_major: 1 @@ -609,7 +854,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -619,7 +864,7 @@ interactions: trailer: {} content_length: 686 uncompressed: false - body: '{"created_at":"2025-12-02T14:29:26.698448Z","endpoints":[{"dns_record":"10bcd861-35bb-48be-8f4a-61b3a9b0704b.mgdb.fr-par.scw.cloud","id":"08b228e1-27ff-4eb6-ac14-e9770454da1d","port":27017,"public_network":{}}],"id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-02T14:29:27.136161Z","retention_days":7},"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' + body: '{"created_at":"2025-12-04T14:05:36.789124Z","endpoints":[{"dns_record":"2b00d5f3-32cc-4373-9e19-d823493d7574.mgdb.fr-par.scw.cloud","id":"e6b73c7c-56a4-470d-b73e-62b492e22cf6","port":27017,"public_network":{}}],"id":"2b00d5f3-32cc-4373-9e19-d823493d7574","name":"test-mongodb-action-snapshot","node_amount":1,"node_type":"mgdb-play2-nano","organization_id":"","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","snapshot_schedule":{"enabled":false,"frequency_hours":24,"last_run":null,"next_update":"2025-12-04T14:05:37.249145Z","retention_days":7},"status":"deleting","tags":[],"version":"7.0","volume":{"size_bytes":5000000000,"type":"sbs_5k"}}' headers: Content-Length: - "686" @@ -628,9 +873,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:33:52 GMT + - Thu, 04 Dec 2025 14:10:24 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -638,11 +883,11 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - 7dbd4af7-44a0-4390-b471-3b80dfe58de1 + - 9c72d3a3-0c80-4a0a-9d83-94e00f082056 status: 200 OK code: 200 - duration: 30.674875ms - - id: 13 + duration: 92.515833ms + - id: 18 request: proto: HTTP/1.1 proto_major: 1 @@ -658,7 +903,7 @@ interactions: headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; darwin; amd64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/10bcd861-35bb-48be-8f4a-61b3a9b0704b + url: https://api.scaleway.com/mongodb/v1/regions/fr-par/instances/2b00d5f3-32cc-4373-9e19-d823493d7574 method: GET response: proto: HTTP/2.0 @@ -668,7 +913,7 @@ interactions: trailer: {} content_length: 129 uncompressed: false - body: '{"message":"resource is not found","resource":"instance","resource_id":"10bcd861-35bb-48be-8f4a-61b3a9b0704b","type":"not_found"}' + body: '{"message":"resource is not found","resource":"instance","resource_id":"2b00d5f3-32cc-4373-9e19-d823493d7574","type":"not_found"}' headers: Content-Length: - "129" @@ -677,9 +922,9 @@ interactions: Content-Type: - application/json Date: - - Tue, 02 Dec 2025 14:35:54 GMT + - Thu, 04 Dec 2025 14:10:44 GMT Server: - - Scaleway API Gateway (fr-par-2;edge01) + - Scaleway API Gateway (fr-par-2;edge02) Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: @@ -687,7 +932,7 @@ interactions: X-Frame-Options: - DENY X-Request-Id: - - fb048cec-e951-46f6-b2b7-10f0341ce115 + - 674c2a4c-3f66-4934-b8dc-cd7968db0ebf status: 404 Not Found code: 404 - duration: 39.340208ms + duration: 32.439125ms From 79b94b477b8c6cdc38e3694534bad03a734931ac Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Fri, 5 Dec 2025 07:56:53 +0100 Subject: [PATCH 5/6] fix: correct linting issues (wsl_v5) and regenerate docs --- internal/services/mongodb/action_instance_snapshot_action.go | 1 + .../services/mongodb/action_instance_snapshot_action_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/services/mongodb/action_instance_snapshot_action.go b/internal/services/mongodb/action_instance_snapshot_action.go index 44f6ad77d5..613028e8e8 100644 --- a/internal/services/mongodb/action_instance_snapshot_action.go +++ b/internal/services/mongodb/action_instance_snapshot_action.go @@ -143,6 +143,7 @@ func (a *InstanceSnapshotAction) Invoke(ctx context.Context, req action.InvokeRe } var expirationTime *time.Time + if !data.ExpiresAt.IsNull() && data.ExpiresAt.ValueString() != "" { expirationRaw := data.ExpiresAt.ValueString() diff --git a/internal/services/mongodb/action_instance_snapshot_action_test.go b/internal/services/mongodb/action_instance_snapshot_action_test.go index 62db212737..70092d335b 100644 --- a/internal/services/mongodb/action_instance_snapshot_action_test.go +++ b/internal/services/mongodb/action_instance_snapshot_action_test.go @@ -95,6 +95,7 @@ func isSnapshotCreated(tt *acctest.TestTools, instanceResourceName, snapshotName } instanceID := rs.Primary.ID + region, id, err := regional.ParseID(instanceID) if err != nil { return fmt.Errorf("failed to parse instance ID: %w", err) From 655f666d4565b8c440bb0ea8a8b83820300a45ba Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Fri, 5 Dec 2025 07:57:05 +0100 Subject: [PATCH 6/6] fix: move expires_at to Optional section in docs --- docs/actions/mongodb_instance_snapshot_action.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/actions/mongodb_instance_snapshot_action.md b/docs/actions/mongodb_instance_snapshot_action.md index c525974ef6..6f60fe78b5 100644 --- a/docs/actions/mongodb_instance_snapshot_action.md +++ b/docs/actions/mongodb_instance_snapshot_action.md @@ -10,11 +10,11 @@ page_title: "Scaleway: scaleway_mongodb_instance_snapshot_action" ### Required -- `expires_at` (String) Expiration date of the snapshot in RFC3339 format (ISO 8601). - `instance_id` (String) MongoDB instance ID to snapshot. Can be a plain UUID or a regional ID. ### Optional +- `expires_at` (String) Expiration date of the snapshot in RFC3339 format (ISO 8601). If not set, the snapshot will not expire. - `name` (String) Name of the snapshot. If not set, a name will be generated. - `region` (String) Region of the MongoDB instance. If not set, the region is derived from the instance_id when possible or from the provider configuration. - `wait` (Boolean) Wait for the snapshot to reach a terminal state before returning.