From daa99406fa837f83ad5fc8b90216dde19c664cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20DELMONT?= Date: Thu, 12 Oct 2023 15:30:32 +0200 Subject: [PATCH 1/3] Add diagnostic on Azure Recovery Service Vault --- .github/workflows/standalone-scenarios.json | 1 + .../106-asr-diagnostics/configuration.tfvars | 150 ++++++++++++++++++ modules/recovery_vault/diagnostics.tf | 1 + modules/recovery_vault/variables.tf | 9 +- recovery_vaults.tf | 1 + 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 examples/recovery_vault/106-asr-diagnostics/configuration.tfvars diff --git a/.github/workflows/standalone-scenarios.json b/.github/workflows/standalone-scenarios.json index 38c6d74801..3bafbd6a8a 100644 --- a/.github/workflows/standalone-scenarios.json +++ b/.github/workflows/standalone-scenarios.json @@ -136,6 +136,7 @@ "recovery_vault/103-asr-with-private-endpoint", "recovery_vault/104-backupvault-with-private-endpoint", "recovery_vault/105-asr-with-network-mapping", + "recovery_vault/106-asr-diagnostics", "redis_cache/103-redis-private-endpoints", "role_mapping/100-simple-role-mapping", "role_mapping/101-function-app-managed-identity", diff --git a/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars b/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars new file mode 100644 index 0000000000..314c84f211 --- /dev/null +++ b/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars @@ -0,0 +1,150 @@ +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"] + } + } + } + } + } + +} diff --git a/modules/recovery_vault/diagnostics.tf b/modules/recovery_vault/diagnostics.tf index 0caaba4e20..50f56b34e9 100644 --- a/modules/recovery_vault/diagnostics.tf +++ b/modules/recovery_vault/diagnostics.tf @@ -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 diff --git a/modules/recovery_vault/variables.tf b/modules/recovery_vault/variables.tf index 5f4359b7e4..aeae2a877a 100644 --- a/modules/recovery_vault/variables.tf +++ b/modules/recovery_vault/variables.tf @@ -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" { diff --git a/recovery_vaults.tf b/recovery_vaults.tf index 2449c3d201..47a45ccb57 100644 --- a/recovery_vaults.tf +++ b/recovery_vaults.tf @@ -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, {}) From b061260c4b7423243da8a3d65ac05716e34ba84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20DELMONT?= Date: Tue, 17 Oct 2023 14:00:12 +0200 Subject: [PATCH 2/3] fix example - missing closing bracket --- examples/recovery_vault/106-asr-diagnostics/configuration.tfvars | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars b/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars index 314c84f211..bd90d904f5 100644 --- a/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars +++ b/examples/recovery_vault/106-asr-diagnostics/configuration.tfvars @@ -53,6 +53,7 @@ diagnostics_destinations = { event_hub_namespace_key = "event_hub_namespace1" } } +} recovery_vaults = { asr1 = { From 0a4aa4ae4e16342b7b2573c9653036aae0c59f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20DELMONT?= Date: Fri, 24 Nov 2023 17:06:41 +0100 Subject: [PATCH 3/3] fix --- .../standalone-scenarios-longrunners.json | 1 + .../virtual_wan.tfvars | 98 +++++++++++++++++++ keyvault_certificate_requests.tf | 3 +- modules/compute/virtual_machine/vm_linux.tf | 7 +- modules/compute/virtual_machine/vm_windows.tf | 3 + modules/networking/virtual_wan/variables.tf | 5 +- .../virtual_hub/point_to_site_gateway.tf | 10 +- .../virtual_wan/virtual_hub/variables.tf | 5 +- modules/networking/virtual_wan/virtual_wan.tf | 1 + .../backup_policies_vm_workload.tf | 78 +++++++++++++++ modules/recovery_vault/outputs.tf | 1 + modules/recovery_vault/recovery_vault.tf | 16 +-- modules/roles/custom_roles/module.tf | 12 ++- .../global_sign.tf | 2 +- .../keyvault_certificate_request/output.tf | 3 + .../keyvault_certificate_request/variables.tf | 1 + networking_virtual_hubs.tf | 1 + networking_virtual_wan.tf | 1 + 18 files changed, 230 insertions(+), 18 deletions(-) create mode 100644 examples/networking/virtual_wan/110-vwan-hub-gw-p2s-keyvault-cert/virtual_wan.tfvars create mode 100644 modules/recovery_vault/backup_policies_vm_workload.tf diff --git a/.github/workflows/standalone-scenarios-longrunners.json b/.github/workflows/standalone-scenarios-longrunners.json index 653d5955ce..dc0d12268f 100644 --- a/.github/workflows/standalone-scenarios-longrunners.json +++ b/.github/workflows/standalone-scenarios-longrunners.json @@ -30,6 +30,7 @@ "networking/virtual_wan/104-vwan-hub-gw-spp", "networking/virtual_wan/105-vwan-hub-route-table", "networking/virtual_wan/109-vwan-vpn-gateway-connection", + "networking/virtual_wan/110-vwan-hub-gw-p2s-keyvault-cert", "redis_cache/100-redis-standard", "redis_cache/101-redis-diagnostics", "redis_cache/102-redis-private", diff --git a/examples/networking/virtual_wan/110-vwan-hub-gw-p2s-keyvault-cert/virtual_wan.tfvars b/examples/networking/virtual_wan/110-vwan-hub-gw-p2s-keyvault-cert/virtual_wan.tfvars new file mode 100644 index 0000000000..6dea339306 --- /dev/null +++ b/examples/networking/virtual_wan/110-vwan-hub-gw-p2s-keyvault-cert/virtual_wan.tfvars @@ -0,0 +1,98 @@ +global_settings = { + default_region = "region1" + regions = { + region1 = "australiaeast" + } +} + +provider_azurerm_features_keyvault = { + // set to true to cleanup the CI + purge_soft_delete_on_destroy = true +} + +resource_groups = { + hub_re1 = { + name = "vnet-hub-re1" + region = "region1" + } +} + +keyvaults = { + vwan-kv = { + name = "vwan-kv" + resource_group_key = "hub_re1" + sku_name = "standard" + creation_policies = { + logged_in_user = { + secret_permissions = ["Set", "Get", "List", "Delete", "Purge"] + } + } + secrets = { + ca_cert = { + name = "ca-cert" + value = <