github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/azurerm/r/virtual_machine_extension.html.markdown (about)

     1  ---
     2  layout: "azurerm"
     3  page_title: "Azure Resource Manager: azure_virtual_machine_extension"
     4  sidebar_current: "docs-azurerm-resource-virtualmachine-extension"
     5  description: |-
     6      Creates a new Virtual Machine Extension to provide post deployment
     7      configuration and run automated tasks.
     8  ---
     9  
    10  # azurerm\_virtual\_machine\_extension
    11  
    12  Creates a new Virtual Machine Extension to provide post deployment configuration
    13  and run automated tasks.
    14  
    15  ## Example Usage
    16  
    17  ```hcl
    18  resource "azurerm_resource_group" "test" {
    19    name     = "acctestrg"
    20    location = "West US"
    21  }
    22  
    23  resource "azurerm_virtual_network" "test" {
    24    name                = "acctvn"
    25    address_space       = ["10.0.0.0/16"]
    26    location            = "West US"
    27    resource_group_name = "${azurerm_resource_group.test.name}"
    28  }
    29  
    30  resource "azurerm_subnet" "test" {
    31    name                 = "acctsub"
    32    resource_group_name  = "${azurerm_resource_group.test.name}"
    33    virtual_network_name = "${azurerm_virtual_network.test.name}"
    34    address_prefix       = "10.0.2.0/24"
    35  }
    36  
    37  resource "azurerm_network_interface" "test" {
    38    name                = "acctni"
    39    location            = "West US"
    40    resource_group_name = "${azurerm_resource_group.test.name}"
    41  
    42    ip_configuration {
    43      name                          = "testconfiguration1"
    44      subnet_id                     = "${azurerm_subnet.test.id}"
    45      private_ip_address_allocation = "dynamic"
    46    }
    47  }
    48  
    49  resource "azurerm_storage_account" "test" {
    50    name                = "accsa"
    51    resource_group_name = "${azurerm_resource_group.test.name}"
    52    location            = "westus"
    53    account_type        = "Standard_LRS"
    54  
    55    tags {
    56      environment = "staging"
    57    }
    58  }
    59  
    60  resource "azurerm_storage_container" "test" {
    61    name                  = "vhds"
    62    resource_group_name   = "${azurerm_resource_group.test.name}"
    63    storage_account_name  = "${azurerm_storage_account.test.name}"
    64    container_access_type = "private"
    65  }
    66  
    67  resource "azurerm_virtual_machine" "test" {
    68    name                  = "acctvm"
    69    location              = "West US"
    70    resource_group_name   = "${azurerm_resource_group.test.name}"
    71    network_interface_ids = ["${azurerm_network_interface.test.id}"]
    72    vm_size               = "Standard_A0"
    73  
    74    storage_image_reference {
    75      publisher = "Canonical"
    76      offer     = "UbuntuServer"
    77      sku       = "14.04.2-LTS"
    78      version   = "latest"
    79    }
    80  
    81    storage_os_disk {
    82      name          = "myosdisk1"
    83      vhd_uri       = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
    84      caching       = "ReadWrite"
    85      create_option = "FromImage"
    86    }
    87  
    88    os_profile {
    89      computer_name  = "hostname"
    90      admin_username = "testadmin"
    91      admin_password = "Password1234!"
    92    }
    93  
    94    os_profile_linux_config {
    95      disable_password_authentication = false
    96    }
    97  
    98    tags {
    99      environment = "staging"
   100    }
   101  }
   102  
   103  resource "azurerm_virtual_machine_extension" "test" {
   104    name                 = "hostname"
   105    location             = "West US"
   106    resource_group_name  = "${azurerm_resource_group.test.name}"
   107    virtual_machine_name = "${azurerm_virtual_machine.test.name}"
   108    publisher            = "Microsoft.OSTCExtensions"
   109    type                 = "CustomScriptForLinux"
   110    type_handler_version = "1.2"
   111  
   112    settings = <<SETTINGS
   113  	{
   114  		"commandToExecute": "hostname"
   115  	}
   116  SETTINGS
   117  
   118    tags {
   119      environment = "Production"
   120    }
   121  }
   122  ```
   123  
   124  ## Argument Reference
   125  
   126  The following arguments are supported:
   127  
   128  * `name` - (Required) The name of the virtual machine extension peering. Changing
   129      this forces a new resource to be created.
   130  
   131  * `location` - (Required) The location where the extension is created. Changing
   132      this forces a new resource to be created.
   133  
   134  * `resource_group_name` - (Required) The name of the resource group in which to
   135      create the virtual network. Changing this forces a new resource to be
   136      created.
   137  
   138  * `virtual_machine_name` - (Required) The name of the virtual machine. Changing
   139      this forces a new resource to be created.
   140  
   141  * `publisher` - (Required) The publisher of the extension, available publishers
   142      can be found by using the Azure CLI.
   143  
   144  * `type` - (Required) The type of extension, available types for a publisher can
   145      be found using the Azure CLI.
   146  
   147  * `type_handler_version` - (Required) Specifies the version of the extension to
   148      use, available versions can be found using the Azure CLI.
   149  
   150  * `auto_upgrade_minor_version` - (Optional) Specifies if the platform deploys
   151      the latest minor version update to the `type_handler_version` specified.
   152  
   153  * `settings` - (Required) The settings passed to the extension, these are
   154      specified as a JSON object in a string.
   155  
   156  * `protected_settings` - (Optional) The protected_settings passed to the
   157      extension, like settings, these are specified as a JSON object in a string.
   158  
   159  ## Attributes Reference
   160  
   161  The following attributes are exported:
   162  
   163  * `id` - The Virtual Machine Extension ID.
   164  
   165  ## Import
   166  
   167  Virtual Machine Extensions can be imported using the `resource id`, e.g.
   168  
   169  ```
   170  terraform import azurerm_virtual_machine_extension.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/myVM/extensions/hostname
   171  ```