github.com/skyscape-cloud-services/terraform@v0.9.2-0.20170609144644-7ece028a1747/examples/azure-vm-specialized-vhd-existing-vnet/main.tf (about)

     1  # provider "azurerm" {
     2  #   subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID"
     3  #   client_id       = "REPLACE-WITH-YOUR-CLIENT-ID"
     4  #   client_secret   = "REPLACE-WITH-YOUR-CLIENT-SECRET"
     5  #   tenant_id       = "REPLACE-WITH-YOUR-TENANT-ID"
     6  # }
     7  
     8  resource "azurerm_resource_group" "rg" {
     9    name     = "${var.resource_group}"
    10    location = "${var.location}"
    11  }
    12  
    13  resource "azurerm_public_ip" "pip" {
    14    name                         = "PublicIp"
    15    location                     = "${var.location}"
    16    resource_group_name          = "${azurerm_resource_group.rg.name}"
    17    public_ip_address_allocation = "Dynamic"
    18    domain_name_label            = "${var.hostname}"
    19  }
    20  
    21  resource "azurerm_network_interface" "nic" {
    22    name                = "nic"
    23    location            = "${var.location}"
    24    resource_group_name = "${azurerm_resource_group.rg.name}"
    25  
    26    ip_configuration {
    27      name                          = "ipconfig"
    28      subnet_id                     = "${var.existing_subnet_id}"
    29      private_ip_address_allocation = "Dynamic"
    30      public_ip_address_id          = "${azurerm_public_ip.pip.id}"
    31    }
    32  }
    33  
    34  resource "azurerm_storage_account" "stor" {
    35    name                = "${var.hostname}"
    36    resource_group_name = "${azurerm_resource_group.rg.name}"
    37    location            = "${var.location}"
    38    account_type        = "${var.storage_account_type}"
    39  }
    40  
    41  resource "azurerm_virtual_machine" "vm" {
    42    name                  = "${var.hostname}"
    43    location              = "${var.location}"
    44    resource_group_name   = "${azurerm_resource_group.rg.name}"
    45    vm_size               = "${var.vm_size}"
    46    network_interface_ids = ["${azurerm_network_interface.nic.id}"]
    47  
    48    storage_os_disk {
    49      name          = "${var.hostname}osdisk1"
    50      image_uri     = "${var.os_disk_vhd_uri}"
    51      vhd_uri       = "https://${var.existing_storage_acct}.blob.core.windows.net/${var.existing_vnet_resource_group}-vhds/${var.hostname}osdisk.vhd"
    52      os_type       = "${var.os_type}"
    53      caching       = "ReadWrite"
    54      create_option = "FromImage"
    55    }
    56  
    57    os_profile {
    58      computer_name  = "${var.hostname}"
    59      admin_username = "${var.admin_username}"
    60      admin_password = "${var.admin_password}"
    61    }
    62  
    63    os_profile_linux_config {
    64      disable_password_authentication = false
    65    }
    66  
    67    boot_diagnostics {
    68      enabled     = true
    69      storage_uri = "${azurerm_storage_account.stor.primary_blob_endpoint}"
    70    }
    71  }