This architecture is for setting up an extended SQL Server Always On backup using Azure. It involves creating a virtual network, subnet, SQL Server virtual machine, and a Recovery Services Vault in Azure.
To set up the architecture mentioned in the document, you would need the following Terraform resources: - azurerm_resource_group - azurerm_virtual_network - azurerm_subnet - azurerm_virtual_machine - azurerm_recovery_services_vault These resources are used to create the necessary infrastructure components such as resource groups, virtual networks, subnets, virtual machines, and recovery services vaults in Azure.

Here's an example of how you might start writing Terraform code to set up some of these components. Please note that this is a high-level example and many details such as networking specifics, security settings, VM sizes, image IDs, SQL configuration, and other settings would need to be filled in based on the actual environment and requirements.
provider "azurerm" {
features {}
}
# Create a resource group if not already existing
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "East US"
}
# Create a virtual network in Azure for the Azure node
resource "azurerm_virtual_network" "example" {
name = "example-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
# Create a subnet for the virtual network
resource "azurerm_subnet" "example" {
name = "internal"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
}
# Create a SQL Server Virtual Machine in Azure
resource "azurerm_virtual_machine" "sql_server" {
name = "sqlvm"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
network_interface_ids = [azurerm_network_interface.example.id]
vm_size = "Standard_DS1_v2"
# other required fields...
storage_os_disk {
name = "myosdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_windows_config {
# windows specific settings...
}
tags = {
environment = "staging"
}
}
# Create a Recovery Services Vault
resource "azurerm_recovery_services_vault" "example" {
name = "example-vault"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "Standard"
}
# Note: VPN setup, Always On setup, and other configurations are not included
# as they require complex configurations and are beyond the scope of this example.
This is a very basic and incomplete example, and a real-world Terraform configuration would be much more complex, especially to properly configure SQL Always On Availability Groups and VPNs.
Please consult the Terraform documentation for each Azure resource, and ensure that you configure each resource with the required arguments. You would also need to ensure that you have the appropriate networking setup for the site-to-site VPN, and this may involve Azure VPN Gateway resources and on-premises configuration that cannot be managed by Terraform.
Additionally, the SQL Always On Availability Groups setup involves configuring the SQL Server instances themselves, which typically requires running SQL scripts and potentially using the remote-exec
provisioner in Terraform to execute these scripts on the VM after it's been provisioned.