resource "azurerm_virtual_machine" "${MyResource}" {
         name = "my-${MyResource}-name"
         resource_group_name = "\${azurerm_resource_group.test.name}"
         location = "West US"
         network_interface_ids = ["\${azurerm_network_interface.test.id}"]
         vm_size = "Standard_A0"
      
         storage_image_reference {
             publisher = "Canonical"
             offer     = "UbuntuServer"
             sku       = "14.04.2-LTS"
             version   = "latest"
         }
      
         storage_os_disk {
             name          = "myosdisk1"
             vhd_uri       = "\${azurerm_storage_account.test.primary_blob_endpoint}\${azurerm_storage_container.test.name}/myosdisk1.vhd"
             caching       = "ReadWrite"
             create_option = "FromImage"
         }
      
         storage_data_disk {
             name          = "datadisk0"
             vhd_uri       = "\${azurerm_storage_account.test.primary_blob_endpoint}\${azurerm_storage_container.test.name}/datadisk0.vhd"
             disk_size_gb  = "1023"
             create_option = "empty"
             lun           = 0
         }
      
         os_profile {
             computer_name  = "hostname"
             admin_username = "testadmin"
             admin_password = "Password1234!"
         }
      
         os_profile_linux_config {
             disable_password_authentication = false
         }
      }
      Terraform language logo

      azurerm_virtual_machine

      Terraform snippets

      This code configures a virtual machine named my-${MyResource}-name with a resource group named ${azurerm_resource_group.test.name}. The location is set to West US and the network interface IDs are set to the test.id values. The virtual machine is set to use a standard_A0 size for the image. Lastly, the os_profile and os_profile_linux_config objects are defined. The os_profile object defines the settings for the Windows installation, and the os_profile_linux_config object disables password authentication.

      Shortcut: tf_azurerm_virtual_machine

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.