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

     1  ---
     2  layout: "vsphere"
     3  page_title: "VMware vSphere: vsphere_virtual_machine"
     4  sidebar_current: "docs-vsphere-resource-virtual-machine"
     5  description: |-
     6    Provides a VMware vSphere virtual machine resource. This can be used to create, modify, and delete virtual machines.
     7  ---
     8  
     9  # vsphere\_virtual\_machine
    10  
    11  Provides a VMware vSphere virtual machine resource. This can be used to create,
    12  modify, and delete virtual machines.
    13  
    14  ## Example Usage
    15  
    16  ```hcl
    17  resource "vsphere_virtual_machine" "web" {
    18    name   = "terraform-web"
    19    vcpu   = 2
    20    memory = 4096
    21  
    22    network_interface {
    23      label = "VM Network"
    24    }
    25  
    26    disk {
    27      template = "centos-7"
    28    }
    29  }
    30  ```
    31  
    32  ## Example Usage VMware Cluster
    33  
    34  ```hcl
    35  resource "vsphere_virtual_machine" "lb" {
    36    name          = "lb01"
    37    folder        = "Loadbalancers"
    38    vcpu          = 2
    39    memory        = 4096
    40    domain        = "MYDOMAIN"
    41    datacenter    = "EAST"
    42    cluster       = "Production Cluster"
    43    resource_pool = "Production Cluster/Resources/Production Servers"
    44  
    45    gateway = "10.20.30.254"
    46  
    47    network_interface {
    48      label              = "10_20_30_VMNet"
    49      ipv4_address       = "10.20.30.40"
    50      ipv4_prefix_length = "24"
    51    }
    52  
    53    disk {
    54      datastore = "EAST/VMFS01-EAST"
    55      template  = "Templates/Centos7"
    56    }
    57  }
    58  ```
    59  
    60  ## Argument Reference
    61  
    62  The following arguments are supported:
    63  
    64  * `name` - (Required) The virtual machine name (cannot contain underscores and must be less than 15 characters)
    65  * `vcpu` - (Required) The number of virtual CPUs to allocate to the virtual machine
    66  * `memory` - (Required) The amount of RAM (in MB) to allocate to the virtual machine
    67  * `memory_reservation` - (Optional) The amount of RAM (in MB) to reserve physical memory resource; defaults to 0 (means not to reserve)
    68  * `datacenter` - (Optional) The name of a Datacenter in which to launch the virtual machine
    69  * `cluster` - (Optional) Name of a Cluster in which to launch the virtual machine
    70  * `resource_pool` (Optional) The name of a Resource Pool in which to launch the virtual machine. Requires full path (see cluster example).
    71  * `gateway` - __Deprecated, please use `network_interface.ipv4_gateway` instead__.
    72  * `domain` - (Optional) A FQDN for the virtual machine; defaults to "vsphere.local"
    73  * `time_zone` - (Optional) The [Linux](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/timezone.html) or [Windows](https://msdn.microsoft.com/en-us/library/ms912391.aspx) time zone to set on the virtual machine. Defaults to "Etc/UTC"
    74  * `dns_suffixes` - (Optional) List of name resolution suffixes for the virtual network adapter
    75  * `dns_servers` - (Optional) List of DNS servers for the virtual network adapter; defaults to 8.8.8.8, 8.8.4.4
    76  * `network_interface` - (Required) Configures virtual network interfaces; see [Network Interfaces](#network-interfaces) below for details.
    77  * `disk` - (Required) Configures virtual disks; see [Disks](#disks) below for details
    78  * `detach_unknown_disks_on_delete` - (Optional) will detach disks not managed by this resource on delete (avoids deletion of disks attached after resource creation outside of Terraform scope).
    79  * `cdrom` - (Optional) Configures a CDROM device and mounts an image as its media; see [CDROM](#cdrom) below for more details.
    80  * `windows_opt_config` - (Optional) Extra options for clones of Windows machines.
    81  * `linked_clone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not.
    82  * `enable_disk_uuid` - (Optional) This option causes the vm to mount disks by uuid on the guest OS.
    83  * `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations.
    84  * `skip_customization` - (Optional) skip virtual machine customization (useful if OS is not in the guest OS support matrix of VMware like "other3xLinux64Guest").
    85  
    86  The `network_interface` block supports:
    87  
    88  * `label` - (Required) Label to assign to this network interface
    89  * `ipv4_address` - (Optional) Static IPv4 to assign to this network interface. Interface will use DHCP if this is left blank.
    90  * `ipv4_prefix_length` - (Optional) prefix length to use when statically assigning an IPv4 address.
    91  * `ipv4_gateway` - (Optional) IPv4 gateway IP address to use.
    92  * `ipv6_address` - (Optional) Static IPv6 to assign to this network interface. Interface will use DHCPv6 if this is left blank.
    93  * `ipv6_prefix_length` - (Optional) prefix length to use when statically assigning an IPv6.
    94  * `ipv6_gateway` - (Optional) IPv6 gateway IP address to use.
    95  * `mac_address` - (Optional) Manual MAC address to assign to this network interface. Will be generated by VMware if not set. ([VMware KB: Setting a static MAC address for a virtual NIC (219)](https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=219))
    96  
    97  The following arguments are maintained for backwards compatibility and may be
    98  removed in a future version:
    99  
   100  * `ip_address` - __Deprecated, please use `ipv4_address` instead__.
   101  * `subnet_mask` - __Deprecated, please use `ipv4_prefix_length` instead__.
   102  
   103  The `windows_opt_config` block supports:
   104  
   105  * `product_key` - (Optional) Serial number for new installation of Windows. This serial number is ignored if the original guest operating system was installed using a volume-licensed CD.
   106  * `admin_password` - (Optional) The password for the new `administrator` account. Omit for passwordless admin (using `""` does not work).
   107  * `domain` - (Optional) Domain that the new machine will be placed into. If `domain`, `domain_user`, and `domain_user_password` are not all set, all three will be ignored.
   108  * `domain_user` - (Optional) User that is a member of the specified domain.
   109  * `domain_user_password` - (Optional) Password for domain user, in plain text.
   110  
   111  <a id="disks"></a>
   112  ## Disks
   113  
   114  The `disk` block supports:
   115  
   116  * `template` - (Required if size and bootable_vmdk_path not provided) Template for this disk.
   117  * `datastore` - (Optional) Datastore for this disk
   118  * `size` - (Required if template and bootable_vmdks_path not provided) Size of this disk (in GB).
   119  * `name` - (Required if size is provided when creating a new disk) This "name" is used for the disk file name in vSphere, when the new disk is created.
   120  * `iops` - (Optional) Number of virtual iops to allocate for this disk.
   121  * `type` - (Optional) 'eager_zeroed' (the default), 'lazy', or 'thin' are supported options.
   122  * `vmdk` - (Required if template and size not provided) Path to a vmdk in a vSphere datastore.
   123  * `bootable` - (Optional) Set to 'true' if a vmdk was given and it should attempt to boot after creation.
   124  * `controller_type` - (Optional) Controller type to attach the disk to.  'scsi' (the default), or 'ide' are supported options.
   125  * `keep_on_remove` - (Optional) Set to 'true' to not delete a disk on removal.
   126  
   127  <a id="cdrom"></a>
   128  ## CDROM
   129  
   130  The `cdrom` block supports:
   131  
   132  * `datastore` - (Required) The name of the datastore where the disk image is stored.
   133  * `path` - (Required) The absolute path to the image within the datastore.
   134  
   135  ## Attributes Reference
   136  
   137  The following attributes are exported:
   138  
   139  * `id` - The instance ID.
   140  * `uuid` - The instance UUID.
   141  * `name` - See Argument Reference above.
   142  * `vcpu` - See Argument Reference above.
   143  * `memory` - See Argument Reference above.
   144  * `datacenter` - See Argument Reference above.
   145  * `network_interface/label` - See Argument Reference above.
   146  * `network_interface/ipv4_address` - See Argument Reference above.
   147  * `network_interface/ipv4_prefix_length` - See Argument Reference above.
   148  * `network_interface/ipv6_address` - Assigned static IPv6 address.
   149  * `network_interface/ipv6_prefix_length` - Prefix length of assigned static IPv6 address.