Skip to content

Commit

Permalink
feat(terraform): define storage recovery vault and policy
Browse files Browse the repository at this point in the history
the vault is where backups are stored
the policy defines the frequency and retention of backups

these are linked to the storage account via azurerm_backup_container_storage_account
  • Loading branch information
thekaveman committed Feb 12, 2024
1 parent cd8bf53 commit 5b57135
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions terraform/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,45 @@ resource "azurerm_storage_account" "main" {
}
}

resource "azurerm_recovery_services_vault" "main" {
name = "rsvcdtcalitp${lower(local.env_letter)}001"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
sku = "Standard"
soft_delete_enabled = true

lifecycle {
ignore_changes = [tags]
}
}

resource "azurerm_backup_container_storage_account" "main" {
resource_group_name = data.azurerm_resource_group.main.name
recovery_vault_name = azurerm_recovery_services_vault.main.name
storage_account_id = azurerm_storage_account.main.id
}

resource "azurerm_backup_policy_file_share" "policy" {
name = "${azurerm_storage_account.main.name}-backup-policy"
resource_group_name = data.azurerm_resource_group.main.name
recovery_vault_name = azurerm_recovery_services_vault.main.name
timezone = "UTC"

backup {
frequency = "Daily"
time = "14:00"
}

retention_daily {
count = 1
}

retention_weekly {
count = 5
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
}
}

resource "azurerm_storage_share" "data" {
name = "benefits-data"
storage_account_name = azurerm_storage_account.main.name
Expand Down

0 comments on commit 5b57135

Please sign in to comment.