azurermBackupPolicyVm
Manages an Azure Backup VM Backup Policy.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "tfex-recovery_vault",
}
);
const azurermRecoveryServicesVaultExample =
new azurerm.recoveryServicesVault.RecoveryServicesVault(this, "example_1", {
location: azurermResourceGroupExample.location,
name: "tfex-recovery-vault",
resource_group_name: azurermResourceGroupExample.name,
sku: "Standard",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermRecoveryServicesVaultExample.overrideLogicalId("example");
const azurermBackupPolicyVmExample = new azurerm.backupPolicyVm.BackupPolicyVm(
this,
"example_2",
{
backup: [
{
frequency: "Daily",
time: "23:00",
},
],
name: "tfex-recovery-vault-policy",
recovery_vault_name: azurermRecoveryServicesVaultExample.name,
resource_group_name: azurermResourceGroupExample.name,
retention_daily: [
{
count: 10,
},
],
retention_monthly: [
{
count: 7,
weekdays: ["Sunday", "Wednesday"],
weeks: ["First", "Last"],
},
],
retention_weekly: [
{
count: 42,
weekdays: ["Sunday", "Wednesday", "Friday", "Saturday"],
},
],
retention_yearly: [
{
count: 77,
months: ["January"],
weekdays: ["Sunday"],
weeks: ["Last"],
},
],
timezone: "UTC",
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBackupPolicyVmExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
-
name
- (Required) Specifies the name of the Backup Policy. Changing this forces a new resource to be created. -
resourceGroupName
- (Required) The name of the resource group in which to create the policy. Changing this forces a new resource to be created. -
recoveryVaultName
- (Required) Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created. -
backup
- (Required) Configures the Policy backup frequency, times & days as documented in thebackup
block below. -
policyType
- (Optional) Type of the Backup Policy. Possible values arev1
andv2
wherev2
stands for the Enhanced Policy. Defaults tov1
. Changing this forces a new resource to be created. -
timezone
- (Optional) Specifies the timezone. the possible values are defined here. Defaults toutc
-
instantRestoreRetentionDays
- (Optional) Specifies the instant restore retention range in days. Possible values are between1
and5
whenpolicyType
isv1
, and1
to30
whenpolicyType
isv2
. -
instantRestoreResourceGroup
- (Optional) Specifies the instant restore resource group name as documented in theinstantRestoreResourceGroup
block below. -
retentionDaily
- (Optional) Configures the policy daily retention as documented in theretentionDaily
block below. Required when backup frequency isdaily
. -
retentionWeekly
- (Optional) Configures the policy weekly retention as documented in theretentionWeekly
block below. Required when backup frequency isweekly
. -
retentionMonthly
- (Optional) Configures the policy monthly retention as documented in theretentionMonthly
block below. -
retentionYearly
- (Optional) Configures the policy yearly retention as documented in theretentionYearly
block below.
The backup
block supports:
-
frequency
- (Required) Sets the backup frequency. Possible values arehourly
,daily
andweekly
. -
time
- (Required) The time of day to perform the backup in 24hour format. -
hourInterval
- (Optional) Interval in hour at which backup is triggered. Possible values are4
,6
,8
and12
. This is used whenfrequency
ishourly
. -
hourDuration
- (Optional) Duration of the backup window in hours. Possible values are between4
and24
This is used whenfrequency
ishourly
.
\~> NOTE: hourDuration
must be multiplier of hourInterval
weekdays
- (Optional) The days of the week to perform backups on. Must be one ofsunday
,monday
,tuesday
,wednesday
,thursday
,friday
orsaturday
. This is used whenfrequency
isweekly
.
The instantRestoreResourceGroup
block supports:
-
prefix
- (Required) The prefix for theinstantRestoreResourceGroup
name. -
suffix
- (Optional) The suffix for theinstantRestoreResourceGroup
name.
The retentionDaily
block supports:
count
- (Required) The number of daily backups to keep. Must be between7
and9999
.
\~> Note: Azure previously allows this field to be set to a minimum of 1 (day) - but for new resources/to update this value on existing Backup Policies - this value must now be at least 7 (days).
The retentionWeekly
block supports:
-
count
- (Required) The number of weekly backups to keep. Must be between1
and9999
-
weekdays
- (Required) The weekday backups to retain. Must be one ofsunday
,monday
,tuesday
,wednesday
,thursday
,friday
orsaturday
.
The retentionMonthly
block supports:
-
count
- (Required) The number of monthly backups to keep. Must be between1
and9999
-
weekdays
- (Required) The weekday backups to retain . Must be one ofsunday
,monday
,tuesday
,wednesday
,thursday
,friday
orsaturday
. -
weeks
- (Required) The weeks of the month to retain backups of. Must be one offirst
,second
,third
,fourth
,last
.
The retentionYearly
block supports:
-
count
- (Required) The number of yearly backups to keep. Must be between1
and9999
-
weekdays
- (Required) The weekday backups to retain . Must be one ofsunday
,monday
,tuesday
,wednesday
,thursday
,friday
orsaturday
. -
weeks
- (Required) The weeks of the month to retain backups of. Must be one offirst
,second
,third
,fourth
,last
. -
months
- (Required) The months of the year to retain backups of. Must be one ofjanuary
,february
,march
,april
,may
,june
,july
,august
,september
,october
,november
anddecember
.
Attributes Reference
The following attributes are exported:
id
- The ID of the VM Backup Policy.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the VM Backup Policy.update
- (Defaults to 30 minutes) Used when updating the VM Backup Policy.read
- (Defaults to 5 minutes) Used when retrieving the VM Backup Policy.delete
- (Defaults to 30 minutes) Used when deleting the VM Backup Policy.
Import
VM Backup Policies can be imported using the resourceId
, e.g.