Skip to content

Commit

Permalink
Add diagnostic on Azure Recovery Service Vault (#1824)
Browse files Browse the repository at this point in the history
* Add diagnostic on Azure Recovery Service Vault

* fix example - missing closing bracket

* fix
  • Loading branch information
kevindelmont authored Nov 29, 2023
1 parent 73d40a7 commit cd5176e
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/standalone-scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"recovery_vault/104-backupvault-with-private-endpoint",
"recovery_vault/105-asr-with-network-mapping",
"recovery_vault/106-backupvault-with-sqldatabase-saphana",
"recovery_vault/107-asr-diagnostics",
"redis_cache/103-redis-private-endpoints",
"role_mapping/100-simple-role-mapping",
"role_mapping/101-function-app-managed-identity",
Expand Down
151 changes: 151 additions & 0 deletions examples/recovery_vault/107-asr-diagnostics/configuration.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
global_settings = {
regions = {
region1 = "australiaeast"
region2 = "australiacentral"
}
}
resource_groups = {
primary = {
name = "sharedsvc_re1"
}
}
diagnostics_definition = {
azure_site_recovery = {
name = "operational_logs_and_metrics"
log_analytics_destination_type = "Dedicated"
categories = {
log = [
# ["Category name", "Diagnostics Enabled(true/false)", "Retention Enabled(true/false)", Retention_period]
["AzureBackupReport", true, true, 0],
["CoreAzureBackup", true, true, 0],
["AddonAzureBackupAlerts", true, true, 0],
["AddonAzureBackupJobs", true, true, 0],
["AddonAzureBackupPolicy", true, true, 0],
["AddonAzureBackupProtectedInstance", true, true, 0],
["AddonAzureBackupStorage", true, true, 0],
["AzureSiteRecoveryJobs", true, true, 0],
["AzureSiteRecoveryEvents", true, true, 0],
["AzureSiteRecoveryReplicatedItems", true, true, 0],
["AzureSiteRecoveryReplicationStats", true, true, 0],
["AzureSiteRecoveryRecoveryPoints", true, true, 0],
["AzureSiteRecoveryReplicationDataUploadRate", true, true, 0],
["AzureSiteRecoveryProtectedDiskDataChurn", true, true, 0],
]
metric = [
["AllMetrics", true, true, 0],
]
}
}
}

diagnostic_event_hub_namespaces = {
event_hub_namespace1 = {
name = "operation_logs"
resource_group_key = "primary"
sku = "Standard"
region = "region1"
}
}

diagnostics_destinations = {
event_hub_namespaces = {
central_logs_example = {
event_hub_namespace_key = "event_hub_namespace1"
}
}
}

recovery_vaults = {
asr1 = {
name = "vault_re1"
resource_group_key = "primary"

diagnostic_profiles = {
azure_site_recovery = {
definition_key = "azure_site_recovery"
destination_type = "event_hub"
destination_key = "central_logs_example"
}
}
region = "region1"

replication_policies = {
repl1 = {
name = "policy1"
resource_group_key = "primary"

recovery_point_retention_in_minutes = 24 * 60
application_consistent_snapshot_frequency_in_minutes = 4 * 60
}
}


backup_policies = {
vms = {
policy1 = {
name = "VMBackupPolicy1"
vault_key = "asr1"
rg_key = "primary"
timezone = "UTC"
instant_restore_retention_days = 5
backup = {
frequency = "Daily"
time = "23:00"
#if not desired daily, can pick weekdays as below:
#weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
}
retention_daily = {
count = 10
}
retention_weekly = {
count = 42
weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"]
}
retention_monthly = {
count = 7
weekdays = ["Sunday", "Wednesday"]
weeks = ["First", "Last"]
}
retention_yearly = {
count = 7
weekdays = ["Sunday"]
weeks = ["Last"]
months = ["January"]
}
}
}

fs = {
policy1 = {
name = "FSBackupPolicy1"
vault_key = "asr1"
rg_key = "primary"
timezone = "UTC"
backup = {
frequency = "Daily"
time = "23:00"
}
retention_daily = {
count = 1
}
retention_weekly = {
count = 1
weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"]
}
retention_monthly = {
count = 1
weekdays = ["Sunday", "Wednesday"]
weeks = ["First", "Last"]
}
retention_yearly = {
count = 2
weekdays = ["Sunday"]
weeks = ["Last"]
months = ["January"]
}
}
}
}
}

}
1 change: 1 addition & 0 deletions modules/recovery_vault/diagnostics.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

module "diagnostics" {
source = "../diagnostics"
count = var.diagnostic_profiles == null ? 0 : 1

resource_id = azurerm_recovery_services_vault.asr.id
resource_location = local.location
Expand Down
9 changes: 8 additions & 1 deletion modules/recovery_vault/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ variable "global_settings" {
description = "Global settings object (see module README.md)"
}

variable "diagnostics" {}
variable "diagnostic_profiles" {
default = {}
}

variable "diagnostics" {
default = null
}

variable "private_endpoints" {}
variable "vnets" {}
variable "client_config" {
Expand Down
1 change: 1 addition & 0 deletions recovery_vaults.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module "recovery_vaults" {
global_settings = local.global_settings
client_config = local.client_config
settings = each.value
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
diagnostics = local.combined_diagnostics
identity = try(each.value.identity, null)
vnets = try(local.combined_objects_networking, {})
Expand Down

0 comments on commit cd5176e

Please sign in to comment.