-2

Team,

I need to provision an Azure VM (Windows/Linux) and I followed the below link to create the image first.

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/build-image-with-packer

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/build-image-with-packer

Now, I have to provision the Virtual Servers from these images using Terraform.

I am able to find the steps to create using a VHD with Terraform but not the managed image.

Can anyone help me or direct me in the correct direction to provision an VM using terraform from Packer built managed images.

Thanks in advance.

2

Use the azurerm_image resource and storage_image_reference:

resource "azurerm_image" "test" {
  name = "myPackerImage"
  location = "East US"
  resource_group_name = "myPackerGroup"
  os_disk {
     os_type ="Windows"
     os_state = "Generalized"
     caching = "ReadWrite"
  }
}

storage_image_reference {
   id = "${azurerm_image.test.id}"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.