terraform/ecc-azure-053-cis_vm_attached_disks/red/vm.tf (54 lines of code) (raw):

resource "azurerm_virtual_network" "this" { name = "${var.prefix}vn-green" address_space = ["10.40.0.0/16"] location = azurerm_resource_group.this.location resource_group_name = azurerm_resource_group.this.name } resource "azurerm_subnet" "this" { name = "${var.prefix}subnet-green" resource_group_name = azurerm_resource_group.this.name virtual_network_name = azurerm_virtual_network.this.name address_prefixes = ["10.40.0.0/24"] } resource "azurerm_network_interface" "nic1" { name = "${var.prefix}-green-nic1" location = azurerm_resource_group.this.location resource_group_name = azurerm_resource_group.this.name ip_configuration { name = "ipconfig1" subnet_id = azurerm_subnet.this.id private_ip_address_allocation = "Dynamic" } } resource "azurerm_network_interface" "nic2" { name = "${var.prefix}-green-nic2" location = azurerm_resource_group.this.location resource_group_name = azurerm_resource_group.this.name ip_configuration { name = "ipconfig2" subnet_id = azurerm_subnet.this.id private_ip_address_allocation = "Dynamic" } } resource "azurerm_linux_virtual_machine" "this" { name = "${var.prefix}-vm-red" location = azurerm_resource_group.this.location resource_group_name = azurerm_resource_group.this.name network_interface_ids = [azurerm_network_interface.nic1.id] size = "Standard_F2s" admin_username = "azureadmin" admin_password = "Password1234!" disable_password_authentication = false source_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "18.04-LTS" version = "latest" } os_disk { name = "${var.prefix}disk_red" caching = "ReadWrite" storage_account_type = "Standard_LRS" # disk_encryption_set_id = azurerm_disk_encryption_set.this.id } tags = var.tags }