我已经成功地使用Terraform创建了每日和每周的备份策略,并且都可以正常工作。然而,Azure门户在政策刀片上显示"即时还原"下的红色标记,说"保留即时恢复快照",该值为2天。我需要将此值更改为5;但是,我没有看到在Terraform中更改它的选项。我想知道我是否应该使用" azurerm_snapshot"资源类型来更改它,或者是否应该使用TF中的解决方法。
resource "azurerm_recovery_services_protection_policy_vm" "backup_policy_weekly" {
name = "${var.RG4VM}-weekly-bkp-policy"
resource_group_name = "${var.RG4VM}"
recovery_vault_name = "${azurerm_recovery_services_vault.backup_vault.name}"
depends_on = ["azurerm_recovery_services_vault.backup_vault"]
timezone = "UTC"
backup {
frequency = "Weekly"
time = "18:30"
weekdays = ["Friday"]
}
retention_weekly {
count = "2"
weekdays = ["Friday"]
}
retention_monthly {
count = "1"
weekdays = ["Friday"]
weeks = ["Last"]
}
}
预期:快照设置为5,因为它是最小值实际:2
谢谢/Asghar
对于您的问题,我只能说Terraform不支持该属性。您可以在Azure REST API中查看以恢复策略为属性instantRpRetentionRangeInDays
,并以此为主体:
{
"properties": {
"backupManagementType": "AzureIaasVM",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunDays": [
"Friday"
],
"scheduleRunTimes": [
"2018-07-30T18:30:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Friday"
],
"retentionTimes": [
"2018-07-30T18:30:00Z"
],
"retentionDuration": {
"count": 5,
"durationType": "Weeks"
}
}
},
"instantRpRetentionRangeInDays": 5,
"timeZone": "UTC",
"protectedItemsCount": 0
}
}
或者您也可以使用Azure模板,并且还可以在其中显示。但是您找不到Terraform中的属性。因此,我建议您可以使用Azure REST API或模板来实现它。