Azure-Terraform / terraform-azurerm-virtual-machine

Terraform Virtual Machine Module
MIT License
8 stars 27 forks source link

Building a VM from a Custom Image #1

Closed wesleyemery closed 3 years ago

wesleyemery commented 3 years ago

The module written in its current state has no ability to use custom images. MBS is using a lift and shift method for their console applications where we build a base image for the VM's that the console applications will be hosted on. Here is an example of a demo deployment:

resource "azurerm_network_interface" "dynamic" { name = local.name location = var.location resource_group_name = var.windows_resource_group tags = module.metadata.tags

ip_configuration { name = "internal" subnet_id = data.azurerm_subnet.windows-subnet.id private_ip_address_allocation = "Dynamic" } }

resource "azurerm_virtual_machine" "vm" { depends_on = [azurerm_network_interface.dynamic, azurerm_storage_account.sa, azurerm_storage_share.ss] location = var.location name = local.name network_interface_ids = [azurerm_network_interface.dynamic.id] resource_group_name = var.windows_resource_group vm_size = var.vm_size

storage_os_disk { create_option = "FromImage" name = local.name } os_profile { admin_username = random_string.username.result computer_name = var.computer_name admin_password = random_password.password.result }

os_profile_windows_config { provision_vm_agent = true enable_automatic_upgrades = true }

storage_image_reference { id = var.image_id }

tags = module.metadata.tags }

Adding an example that used a custom image would also be useful.

jhisc commented 3 years ago

Hey @wesleyemery - Can you check this meets your needs please?

https://github.com/Azure-Terraform/terraform-azurerm-virtual-machine/pull/2

jhisc commented 3 years ago

Change has been merged & Tagged v1.1.0