Terraform - Linux VM issue not being created

Viewed 31

I am following along a YouTube video on "Learn Terraform with Azure by Building a Dev Environment – Full Course for Beginners" not sure if i can post links but (https://www.youtube.com/watch?v=V53AHWun17s) around minute 53, is where i am having the issue. When implementing this section of the code i get this error:

resource "azurerm_linux_virtual_machine" "mtc-vm" {
  name                  = "mtc-vm"
  resource_group_name   = azurerm_resource_group.mtc-rg.name
  location              = azurerm_resource_group.mtc rg.location
  size                  = "Standard_B1s"
  admin_username        = "adminuser"
  network_interface_ids = [azurerm_network_interface.mtc-nic.id]

  admin_ssh_key {
    username   = "adminuser"
    public_key = file("~/.ssh/mtcazurekey.pub")
  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {

    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "18.04-LTS"
    version   = "latest"
  }

  tags = {
    "environment" = "dev"
  }
}



Error: creating Linux Virtual Machine: (Name "mtc-vm" / Resource Group "mtc-resources"): compute.VirtualMachinesclient#CreateOru pdate: Failure sending request: StatusCode=404 -- Original Error: Code="Platform ImageNotFound" Message="The platform image 'Canoni cal:UbuntuServer:16.04 LTS:latest' is not available. Verify that all fields in the storage profile are correct. For more details a bout storage profile information, please refer to https://aka.ms/storageprofile" target="imageReference"

with azurerm linux virtual machine.mtc-vm, on main.tf line 97, in resource "azurerm_linux_virtual machine" "mtc-vm" : 97: resource "azurerm_linux_virtual_machine" "mtc-vm" {

1 Answers

Based on the comments. The issue was caused by using old Ubuntu 16.04 LTS:latest in the actual TF code. Changing to 18.04-LTS and modify other settings (not clarified which ones), fixed the issue.

Related