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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3627.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mongodb_instance_backup_rule: add new params
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ResourceTencentCloudMongodbInstanceBackupRule() *schema.Resource {
Required: true,
ForceNew: true,
Type: schema.TypeString,
Description: "Instance id.",
Description: "Instance ID.",
},

"backup_method": {
Expand All @@ -44,12 +44,66 @@ func ResourceTencentCloudMongodbInstanceBackupRule() *schema.Resource {
Description: "Set the start time for automatic backup. The value range is: [0,23]. For example, setting this parameter to 2 means that backup starts at 02:00.",
},

"backup_frequency": {
Type: schema.TypeInt,
Optional: true,
Description: "Automatic backup frequency, for internal display, default value is 24h.",
},

"notify": {
Type: schema.TypeBool,
Optional: true,
Description: "Set whether to send failure alerts when automatic backup errors occur.\n- true: Send.\n- false: Do not send.",
},

"backup_retention_period": {
Optional: true,
Computed: true,
Type: schema.TypeInt,
Description: "Specify the number of days to save backup data. The default is 7 days, and the support settings are 7, 30, 90, 180, 365.",
},

"active_weekdays": {
Type: schema.TypeString,
Optional: true,
Description: "Which days of the week to backup, 0-6, comma separated. Only effective for advanced backup.",
},

"long_term_unit": {
Type: schema.TypeString,
Optional: true,
Description: "Long-term retention cycle, weekly, monthly, empty means not enabled.",
},

"long_term_active_days": {
Type: schema.TypeString,
Optional: true,
Description: "Which days to retain long-term, week 0-6, month 1-31, comma separated.",
},

"long_term_expired_days": {
Type: schema.TypeInt,
Optional: true,
Description: "How many days to retain long-term backups.",
},

"oplog_expired_days": {
Type: schema.TypeInt,
Optional: true,
Description: "How many days to retain incremental backups.",
},

"backup_version": {
Type: schema.TypeInt,
Optional: true,
Description: "Backup version. Old version backup is 0, advanced backup is 1. Set this value to 1 when enabling advanced backup.",
},

"alarm_water_level": {
Type: schema.TypeInt,
Optional: true,
Description: "Alert threshold. Range: 50-300.",
},
},
}
}
Expand Down Expand Up @@ -139,10 +193,46 @@ func resourceTencentCloudMongodbInstanceBackupRuleUpdate(d *schema.ResourceData,
request.BackupTime = helper.IntUint64(v.(int))
}

if v, ok := d.GetOkExists("backup_frequency"); ok {
request.BackupFrequency = helper.IntUint64(v.(int))
}

if v, ok := d.GetOkExists("notify"); ok {
request.Notify = helper.Bool(v.(bool))
}

if v, ok := d.GetOkExists("backup_retention_period"); ok {
request.BackupRetentionPeriod = helper.IntUint64(v.(int))
}

if v, ok := d.GetOk("active_weekdays"); ok {
request.ActiveWeekdays = helper.String(v.(string))
}

if v, ok := d.GetOk("long_term_unit"); ok {
request.LongTermUnit = helper.String(v.(string))
}

if v, ok := d.GetOk("long_term_active_days"); ok {
request.LongTermActiveDays = helper.String(v.(string))
}

if v, ok := d.GetOkExists("long_term_expired_days"); ok {
request.LongTermExpiredDays = helper.IntInt64(v.(int))
}

if v, ok := d.GetOkExists("oplog_expired_days"); ok {
request.OplogExpiredDays = helper.IntInt64(v.(int))
}

if v, ok := d.GetOkExists("backup_version"); ok {
request.BackupVersion = helper.IntInt64(v.(int))
}

if v, ok := d.GetOkExists("alarm_water_level"); ok {
request.AlarmWaterLevel = helper.IntInt64(v.(int))
}

request.InstanceId = &instanceId
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMongodbClient().SetBackupRules(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "tencentcloud_mongodb_instance_backup_rule" "example" {
backup_method = 0
backup_time = 10
backup_retention_period = 7
backup_version = 1
}
```

Expand Down
14 changes: 13 additions & 1 deletion website/docs/r/mongodb_instance_backup_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "tencentcloud_mongodb_instance_backup_rule" "example" {
backup_method = 0
backup_time = 10
backup_retention_period = 7
backup_version = 1
}
```

Expand All @@ -31,8 +32,19 @@ The following arguments are supported:
- 1: Physical backup;
- 3: Snapshot backup (supported only in cloud disk version).
* `backup_time` - (Required, Int) Set the start time for automatic backup. The value range is: [0,23]. For example, setting this parameter to 2 means that backup starts at 02:00.
* `instance_id` - (Required, String, ForceNew) Instance id.
* `instance_id` - (Required, String, ForceNew) Instance ID.
* `active_weekdays` - (Optional, String) Which days of the week to backup, 0-6, comma separated. Only effective for advanced backup.
* `alarm_water_level` - (Optional, Int) Alert threshold. Range: 50-300.
* `backup_frequency` - (Optional, Int) Automatic backup frequency, for internal display, default value is 24h.
* `backup_retention_period` - (Optional, Int) Specify the number of days to save backup data. The default is 7 days, and the support settings are 7, 30, 90, 180, 365.
* `backup_version` - (Optional, Int) Backup version. Old version backup is 0, advanced backup is 1. Set this value to 1 when enabling advanced backup.
* `long_term_active_days` - (Optional, String) Which days to retain long-term, week 0-6, month 1-31, comma separated.
* `long_term_expired_days` - (Optional, Int) How many days to retain long-term backups.
* `long_term_unit` - (Optional, String) Long-term retention cycle, weekly, monthly, empty means not enabled.
* `notify` - (Optional, Bool) Set whether to send failure alerts when automatic backup errors occur.
- true: Send.
- false: Do not send.
* `oplog_expired_days` - (Optional, Int) How many days to retain incremental backups.

## Attributes Reference

Expand Down
Loading