Skip to content

Commit a47fac0

Browse files
authored
feat(mongodb): set point_in_time_window_hours as required (#860)
* feat(mongodb): set point_in_time_window_hours as required * docs update
1 parent 9b1c658 commit a47fac0

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

docs/resources/mongodbflex_instance.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resource "stackit_mongodbflex_instance" "example" {
1919
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
2020
flavor = {
2121
cpu = 1
22-
ram = 8
22+
ram = 4
2323
}
2424
replicas = 1
2525
storage = {
@@ -28,8 +28,9 @@ resource "stackit_mongodbflex_instance" "example" {
2828
}
2929
version = "7.0"
3030
options = {
31-
type = "Single"
32-
snapshot_retention_days = 3
31+
type = "Single"
32+
snapshot_retention_days = 3
33+
point_in_time_window_hours = 30
3334
}
3435
backup_schedule = "0 0 * * *"
3536
}
@@ -74,13 +75,13 @@ Read-Only:
7475

7576
Required:
7677

78+
- `point_in_time_window_hours` (Number) The number of hours back in time the point-in-time recovery feature will be able to recover.
7779
- `type` (String) Type of the MongoDB Flex instance. Supported values are: `Replica`, `Sharded`, `Single`.
7880

7981
Optional:
8082

8183
- `daily_snapshot_retention_days` (Number) The number of days that daily backups will be retained.
8284
- `monthly_snapshot_retention_months` (Number) The number of months that monthly backups will be retained.
83-
- `point_in_time_window_hours` (Number) The number of hours back in time the point-in-time recovery feature will be able to recover.
8485
- `snapshot_retention_days` (Number) The number of days that continuous backups (controlled via the `backup_schedule`) will be retained.
8586
- `weekly_snapshot_retention_weeks` (Number) The number of weeks that weekly backups will be retained.
8687

examples/resources/stackit_mongodbflex_instance/resource.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resource "stackit_mongodbflex_instance" "example" {
44
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
55
flavor = {
66
cpu = 1
7-
ram = 8
7+
ram = 4
88
}
99
replicas = 1
1010
storage = {
@@ -13,8 +13,9 @@ resource "stackit_mongodbflex_instance" "example" {
1313
}
1414
version = "7.0"
1515
options = {
16-
type = "Single"
17-
snapshot_retention_days = 3
16+
type = "Single"
17+
snapshot_retention_days = 3
18+
point_in_time_window_hours = 30
1819
}
1920
backup_schedule = "0 0 * * *"
2021
}

stackit/internal/services/mongodbflex/instance/resource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
291291
},
292292
"point_in_time_window_hours": schema.Int64Attribute{
293293
Description: descriptions["point_in_time_window_hours"],
294-
Optional: true,
295-
Computed: true,
294+
Required: true,
296295
PlanModifiers: []planmodifier.Int64{
297296
int64planmodifier.UseStateForUnknown(),
298297
},

stackit/internal/services/mongodbflex/mongodbflex_acc_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var instanceResource = map[string]string{
3939
"snapshot_retention_days": "4",
4040
"snapshot_retention_days_updated": "3",
4141
"daily_snapshot_retention_days": "1",
42+
"point_in_time_window_hours": "30",
4243
}
4344

4445
// User resource data
@@ -71,6 +72,7 @@ func configResources(version, backupSchedule, snapshotRetentionDays string) stri
7172
type = "%s"
7273
snapshot_retention_days = %s
7374
daily_snapshot_retention_days = %s
75+
point_in_time_window_hours = %s
7476
}
7577
backup_schedule = "%s"
7678
}
@@ -96,6 +98,7 @@ func configResources(version, backupSchedule, snapshotRetentionDays string) stri
9698
instanceResource["options_type"],
9799
snapshotRetentionDays,
98100
instanceResource["daily_snapshot_retention_days"],
101+
instanceResource["point_in_time_window_hours"],
99102
backupSchedule,
100103
userResource["username"],
101104
userResource["role"],
@@ -129,6 +132,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
129132
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
130133
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days"]),
131134
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.daily_snapshot_retention_days", instanceResource["daily_snapshot_retention_days"]),
135+
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
132136
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule"]),
133137

134138
// User
@@ -191,6 +195,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
191195
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
192196
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days"]),
193197
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.daily_snapshot_retention_days", instanceResource["daily_snapshot_retention_days"]),
198+
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
194199
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule_read"]),
195200

196201
// User data
@@ -274,6 +279,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
274279
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "version", instanceResource["version_updated"]),
275280
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
276281
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days_updated"]),
282+
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
277283
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule_updated"]),
278284
),
279285
},

0 commit comments

Comments
 (0)