# The workstation, the session records, and the analysts' access. resource "azurerm_network_interface" "workstation" { name = "nic-forensic-workstation" location = azurerm_resource_group.forensics.location resource_group_name = azurerm_resource_group.forensics.name tags = local.tags ip_configuration { name = "internal" subnet_id = azurerm_subnet.analysis.id private_ip_address_allocation = "Static" private_ip_address = cidrhost(local.analysis_prefix, 4) } } # Encryption at host covers the temporary disk and caches as well as the # managed disks, which is where memory images land while they are worked on. resource "azurerm_linux_virtual_machine" "workstation" { name = "forensic-workstation" location = azurerm_resource_group.forensics.location resource_group_name = azurerm_resource_group.forensics.name size = var.vm_size admin_username = "analyst" disable_password_authentication = true encryption_at_host_enabled = true allow_extension_operations = false secure_boot_enabled = true vtpm_enabled = true network_interface_ids = [azurerm_network_interface.workstation.id] tags = local.tags admin_ssh_key { username = "analyst" public_key = var.analyst_ssh_public_key } os_disk { caching = "ReadWrite" storage_account_type = "Premium_LRS" disk_size_gb = 512 } source_image_reference { publisher = "Canonical" offer = "ubuntu-24_04-lts" sku = "server" version = "latest" } identity { type = "SystemAssigned" } # A newer image must not rebuild the workstation mid-case. lifecycle { ignore_changes = [source_image_reference] } } # Read, never write or delete, on the evidence. resource "azurerm_role_assignment" "evidence_reader" { scope = var.evidence_storage_account_id role_definition_name = "Storage Blob Data Reader" principal_id = azurerm_linux_virtual_machine.workstation.identity[0].principal_id } # --------------------------------------------------------------------------- # Bastion: the only way in # --------------------------------------------------------------------------- resource "azurerm_public_ip" "bastion" { name = "pip-forensics-bastion" location = azurerm_resource_group.forensics.location resource_group_name = azurerm_resource_group.forensics.name allocation_method = "Static" sku = "Standard" tags = local.tags } # Copy and paste and file transfer are the easy ways data leaves through a # session, so both are off. Evidence comes in from storage; findings go out # through your case system, not through the session. resource "azurerm_bastion_host" "forensics" { name = "bastion-forensics" location = azurerm_resource_group.forensics.location resource_group_name = azurerm_resource_group.forensics.name sku = "Standard" tunneling_enabled = true shareable_link_enabled = false ip_connect_enabled = false copy_paste_enabled = false file_copy_enabled = false tags = local.tags ip_configuration { name = "bastion" subnet_id = azurerm_subnet.bastion.id public_ip_address_id = azurerm_public_ip.bastion.id } depends_on = [azurerm_subnet_network_security_group_association.bastion] } resource "azurerm_monitor_diagnostic_setting" "bastion" { name = "sessions" target_resource_id = azurerm_bastion_host.forensics.id log_analytics_workspace_id = azurerm_log_analytics_workspace.forensics.id enabled_log { category = "BastionAuditLogs" } } # Reader on Bastion and on the workstation is what a Bastion connection needs. resource "azurerm_role_assignment" "analysts_bastion" { scope = azurerm_bastion_host.forensics.id role_definition_name = "Reader" principal_id = var.analyst_group_object_id } resource "azurerm_role_assignment" "analysts_workstation" { scope = azurerm_linux_virtual_machine.workstation.id role_definition_name = "Reader" principal_id = var.analyst_group_object_id } resource "azurerm_role_assignment" "analysts_nic" { scope = azurerm_network_interface.workstation.id role_definition_name = "Reader" principal_id = var.analyst_group_object_id }