feat(mongodb): set point_in_time_window_hours as required (#860)

* feat(mongodb): set point_in_time_window_hours as required

* docs update
This commit is contained in:
Marcel Jacek 2025-05-23 14:06:13 +02:00 committed by GitHub
parent 9b1c658575
commit a47fac0ae7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 9 deletions

View file

@ -19,7 +19,7 @@ resource "stackit_mongodbflex_instance" "example" {
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
flavor = {
cpu = 1
ram = 8
ram = 4
}
replicas = 1
storage = {
@ -28,8 +28,9 @@ resource "stackit_mongodbflex_instance" "example" {
}
version = "7.0"
options = {
type = "Single"
snapshot_retention_days = 3
type = "Single"
snapshot_retention_days = 3
point_in_time_window_hours = 30
}
backup_schedule = "0 0 * * *"
}
@ -74,13 +75,13 @@ Read-Only:
Required:
- `point_in_time_window_hours` (Number) The number of hours back in time the point-in-time recovery feature will be able to recover.
- `type` (String) Type of the MongoDB Flex instance. Supported values are: `Replica`, `Sharded`, `Single`.
Optional:
- `daily_snapshot_retention_days` (Number) The number of days that daily backups will be retained.
- `monthly_snapshot_retention_months` (Number) The number of months that monthly backups will be retained.
- `point_in_time_window_hours` (Number) The number of hours back in time the point-in-time recovery feature will be able to recover.
- `snapshot_retention_days` (Number) The number of days that continuous backups (controlled via the `backup_schedule`) will be retained.
- `weekly_snapshot_retention_weeks` (Number) The number of weeks that weekly backups will be retained.

View file

@ -4,7 +4,7 @@ resource "stackit_mongodbflex_instance" "example" {
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
flavor = {
cpu = 1
ram = 8
ram = 4
}
replicas = 1
storage = {
@ -13,8 +13,9 @@ resource "stackit_mongodbflex_instance" "example" {
}
version = "7.0"
options = {
type = "Single"
snapshot_retention_days = 3
type = "Single"
snapshot_retention_days = 3
point_in_time_window_hours = 30
}
backup_schedule = "0 0 * * *"
}

View file

@ -291,8 +291,7 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
},
"point_in_time_window_hours": schema.Int64Attribute{
Description: descriptions["point_in_time_window_hours"],
Optional: true,
Computed: true,
Required: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},

View file

@ -39,6 +39,7 @@ var instanceResource = map[string]string{
"snapshot_retention_days": "4",
"snapshot_retention_days_updated": "3",
"daily_snapshot_retention_days": "1",
"point_in_time_window_hours": "30",
}
// User resource data
@ -71,6 +72,7 @@ func configResources(version, backupSchedule, snapshotRetentionDays string) stri
type = "%s"
snapshot_retention_days = %s
daily_snapshot_retention_days = %s
point_in_time_window_hours = %s
}
backup_schedule = "%s"
}
@ -96,6 +98,7 @@ func configResources(version, backupSchedule, snapshotRetentionDays string) stri
instanceResource["options_type"],
snapshotRetentionDays,
instanceResource["daily_snapshot_retention_days"],
instanceResource["point_in_time_window_hours"],
backupSchedule,
userResource["username"],
userResource["role"],
@ -129,6 +132,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.daily_snapshot_retention_days", instanceResource["daily_snapshot_retention_days"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule"]),
// User
@ -191,6 +195,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days"]),
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.daily_snapshot_retention_days", instanceResource["daily_snapshot_retention_days"]),
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
resource.TestCheckResourceAttr("data.stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule_read"]),
// User data
@ -274,6 +279,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "version", instanceResource["version_updated"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.type", instanceResource["options_type"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.snapshot_retention_days", instanceResource["snapshot_retention_days_updated"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "options.point_in_time_window_hours", instanceResource["point_in_time_window_hours"]),
resource.TestCheckResourceAttr("stackit_mongodbflex_instance.instance", "backup_schedule", instanceResource["backup_schedule_updated"]),
),
},