This terraform module enable VM backup protection on the specified instance.
Module version | Terraform version | AzureRM version |
---|---|---|
>= 6.x.x | 1.x | >= 3.0 |
>= 5.x.x | 0.15.x | >= 2.0 |
>= 4.x.x | 0.13.x / 0.14.x | >= 2.0 |
>= 3.x.x | 0.12.x | >= 2.0 |
>= 2.x.x | 0.12.x | < 2.0 |
< 2.x.x | 0.11.x | < 2.0 |
This module is optimized to work with the Claranet terraform-wrapper tool
which set some terraform variables in the environment needed by this module.
More details about variables set by the terraform-wrapper
available in the documentation.
module "azure_region" {
source = "claranet/regions/azurerm"
version = "x.x.x"
azure_region = var.azure_region
}
module "rg" {
source = "claranet/rg/azurerm"
version = "x.x.x"
location = module.azure_region.location
client_name = var.client_name
environment = var.environment
stack = var.stack
}
module "logs" {
source = "claranet/run-common/azurerm//modules/logs"
version = "x.x.x"
client_name = var.client_name
location = module.azure_region.location
location_short = module.azure_region.location_short
environment = var.environment
stack = var.stack
resource_group_name = module.rg.resource_group_name
}
module "vm_backup_vault" {
source = "claranet/run-iaas/azurerm//modules/backup"
version = "x.x.x"
location = module.azure_region.location
location_short = module.azure_region.location_short
client_name = var.client_name
environment = var.environment
stack = var.stack
resource_group_name = module.rg.resource_group_name
logs_destinations_ids = [
module.logs.logs_storage_account_id,
module.logs.log_analytics_workspace_id
]
}
module "azure_network_vnet" {
source = "claranet/vnet/azurerm"
version = "x.x.x"
environment = var.environment
location = module.azure_region.location
location_short = module.azure_region.location_short
client_name = var.client_name
stack = var.stack
resource_group_name = module.rg.resource_group_name
vnet_cidr = ["10.10.0.0/16"]
}
module "azure_network_subnet" {
source = "claranet/subnet/azurerm"
version = "x.x.x"
environment = var.environment
location_short = module.azure_region.location_short
client_name = var.client_name
stack = var.stack
resource_group_name = module.rg.resource_group_name
virtual_network_name = module.azure_network_vnet.virtual_network_name
subnet_cidr_list = ["10.10.10.0/24"]
}
module "az_monitor" {
source = "claranet/run-iaas/azurerm//modules/vm-monitoring"
version = "x.x.x"
client_name = var.client_name
location = module.azure_region.location
location_short = module.azure_region.location_short
environment = var.environment
stack = var.stack
resource_group_name = module.rg.resource_group_name
log_analytics_workspace_id = module.logs.log_analytics_workspace_id
extra_tags = {
foo = "bar"
}
}
resource "azurerm_availability_set" "vm_avset" {
name = "${var.stack}-${var.client_name}-${module.azure_region.location_short}-${var.environment}-as"
location = module.azure_region.location
resource_group_name = module.rg.resource_group_name
managed = true
}
module "vm" {
source = "claranet/linux-vm/azurerm"
version = "x.x.x"
location = module.azure_region.location
location_short = module.azure_region.location_short
client_name = var.client_name
environment = var.environment
stack = var.stack
resource_group_name = module.rg.resource_group_name
subnet_id = module.azure_network_subnet.subnet_id
vm_size = "Standard_B2s"
custom_name = "app-${var.stack}-${var.client_name}-${module.azure_region.location_short}-${var.environment}-vm"
admin_username = var.vm_administrator_login
ssh_public_key = var.ssh_public_key
diagnostics_storage_account_name = module.logs.logs_storage_account_name
diagnostics_storage_account_sas_token = null # used by legacy agent only
azure_monitor_data_collection_rule_id = module.az_monitor.data_collection_rule_id
log_analytics_workspace_guid = module.logs.log_analytics_workspace_guid
log_analytics_workspace_key = module.logs.log_analytics_workspace_primary_key
availability_set_id = azurerm_availability_set.vm_avset.id
# or use Availability Zone
# zone_id = 1
vm_image = {
publisher = "Debian"
offer = "debian-10"
sku = "10"
version = "latest"
}
storage_data_disk_config = {
appli_data_disk = {
name = "appli_data_disk"
disk_size_gb = 512
lun = 0
storage_account_type = "Standard_LRS"
extra_tags = {
some_data_disk_tag = "some_data_disk_tag_value"
}
}
logs_disk = {
# Used to define Logical Unit Number (LUN) parameter
lun = 10
disk_size_gb = 64
caching = "ReadWrite"
extra_tags = {
some_data_disk_tag = "some_data_disk_tag_value"
}
}
}
}
module "vm_backup" {
source = "claranet/vm-backup/azurerm"
version = "x.x.x"
resource_group_name = module.rg.resource_group_name
backup_policy_id = module.vm_backup_vault.vm_backup_policy_id
backup_recovery_vault_name = module.vm_backup_vault.recovery_vault_name
vm_id = module.vm.vm_id
}
Name | Version |
---|---|
azurerm | >= 2.0 |
No modules.
Name | Type |
---|---|
azurerm_backup_protected_vm.recovery_vault_backup_enable | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
backup_policy_id | Backup policy to attach | string |
n/a | yes |
backup_recovery_vault_name | Backup recovery vault name | string |
n/a | yes |
resource_group_name | Name of the resource group | string |
n/a | yes |
vm_id | Azure VM ID to attach to the Backup policy | string |
n/a | yes |
No outputs.
Enable backup protection via Azure CLI
Enable backup protection via Terraform: terraform.io/docs/providers/azurerm/r/recovery_services_protection_policy_vm.html