azurerm_virtual_machine

    0

    0

    lucycodes42

    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

    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
       }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.