azurermBackupProtectedFileShare
Manages an Azure Backup Protected File Share to enable backups for file shares within an Azure Storage Account
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 azurermStorageAccountSa = new azurerm.storageAccount.StorageAccount(
this,
"sa",
{
account_replication_type: "LRS",
account_tier: "Standard",
location: azurermResourceGroupExample.location,
name: "examplesa",
resource_group_name: azurermResourceGroupExample.name,
}
);
const azurermStorageShareExample = new azurerm.storageShare.StorageShare(
this,
"example_2",
{
name: "example-share",
quota: 1,
storage_account_name: azurermStorageAccountSa.name,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageShareExample.overrideLogicalId("example");
const azurermRecoveryServicesVaultVault =
new azurerm.recoveryServicesVault.RecoveryServicesVault(this, "vault", {
location: azurermResourceGroupExample.location,
name: "tfex-recovery-vault",
resource_group_name: azurermResourceGroupExample.name,
sku: "Standard",
});
const azurermBackupContainerStorageAccountProtectionContainer =
new azurerm.backupContainerStorageAccount.BackupContainerStorageAccount(
this,
"protection-container",
{
recovery_vault_name: azurermRecoveryServicesVaultVault.name,
resource_group_name: azurermResourceGroupExample.name,
storage_account_id: azurermStorageAccountSa.id,
}
);
const azurermBackupPolicyFileShareExample =
new azurerm.backupPolicyFileShare.BackupPolicyFileShare(this, "example_5", {
backup: [
{
frequency: "Daily",
time: "23:00",
},
],
name: "tfex-recovery-vault-policy",
recovery_vault_name: azurermRecoveryServicesVaultVault.name,
resource_group_name: azurermResourceGroupExample.name,
retention_daily: [
{
count: 10,
},
],
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBackupPolicyFileShareExample.overrideLogicalId("example");
new azurerm.backupProtectedFileShare.BackupProtectedFileShare(this, "share1", {
backup_policy_id: azurermBackupPolicyFileShareExample.id,
recovery_vault_name: azurermRecoveryServicesVaultVault.name,
resource_group_name: azurermResourceGroupExample.name,
source_file_share_name: azurermStorageShareExample.name,
source_storage_account_id:
azurermBackupContainerStorageAccountProtectionContainer.storageAccountId,
});
Argument Reference
The following arguments are supported:
-
resourceGroupName
- (Required) The name of the resource group in which to create the Azure Backup Protected File Share. 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. -
sourceStorageAccountId
- (Required) Specifies the ID of the storage account of the file share to backup. Changing this forces a new resource to be created.
-> NOTE The storage account must already be registered with the recovery vault in order to backup shares within the account. You can use the azurermBackupContainerStorageAccount
resource or the Register-AzRecoveryServicesBackupContainer PowerShell cmdlet to register a storage account with a vault. When using the azurermBackupContainerStorageAccount
resource to register, you can use dependsOn
to explicitly declare the dependency. It will make sure that the registration is completed before creating the azurermBackupProtectedFileShare
resource.
-
sourceFileShareName
- (Required) Specifies the name of the file share to backup. Changing this forces a new resource to be created. -
backupPolicyId
- (Required) Specifies the ID of the backup policy to use. The policy must be an Azure File Share backup policy. Other types are not supported.
Attributes Reference
The following attributes are exported:
id
- The ID of the Backup File Share.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 80 minutes) Used when creating the Backup File Share.update
- (Defaults to 80 minutes) Used when updating the Backup File Share.read
- (Defaults to 5 minutes) Used when retrieving the Backup File Share.delete
- (Defaults to 80 minutes) Used when deleting the Backup File Share.
Import
Azure Backup Protected File Shares can be imported using the resourceId
, e.g.
terraform import azurerm_backup_protected_file_share.item1 "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/example-recovery-vault/backupFabrics/Azure/protectionContainers/StorageContainer;storage;group2;example-storage-account/protectedItems/AzureFileShare;3f6e3108a45793581bcbd1c61c87a3b2ceeb4ff4bc02a95ce9d1022b23722935"
-> NOTE The ID requires quoting as there are semicolons. This user unfriendly ID can be found in the Deployments of the used resourcegroup, look for an Deployment which starts with configureAfsProtection
, click then goToResource
.