github.com/danrjohnson/terraform@v0.7.0-rc2.0.20160627135212-d0fc1fa086ff/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown (about)

     1  ---
     2  layout: "openstack"
     3  page_title: "OpenStack: openstack_compute_instance_v2"
     4  sidebar_current: "docs-openstack-resource-compute-instance-v2"
     5  description: |-
     6    Manages a V2 VM instance resource within OpenStack.
     7  ---
     8  
     9  # openstack\_compute\_instance_v2
    10  
    11  Manages a V2 VM instance resource within OpenStack.
    12  
    13  ## Example Usage
    14  
    15  ### Basic Instance
    16  
    17  ```
    18  resource "openstack_compute_instance_v2" "basic" {
    19    name = "basic"
    20    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
    21    flavor_id = "3"
    22    key_pair = "my_key_pair_name"
    23    security_groups = ["default"]
    24  
    25    metadata {
    26      this = "that"
    27    }
    28  
    29    network {
    30      name = "my_network"
    31    }
    32  }
    33  ```
    34  
    35  ### Instance With Attached Volume
    36  
    37  ```
    38  resource "openstack_blockstorage_volume_v1" "myvol" {
    39    name = "myvol"
    40    size = 1
    41  }
    42  
    43  resource "openstack_compute_instance_v2" "volume-attached" {
    44    name = "volume-attached"
    45    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
    46    flavor_id = "3"
    47    key_pair = "my_key_pair_name"
    48    security_groups = ["default"]
    49  
    50    network {
    51      name = "my_network"
    52    }
    53  
    54    volume {
    55      volume_id = "${openstack_blockstorage_volume_v1.myvol.id}"
    56    }
    57  }
    58  ```
    59  
    60  ### Boot From Volume
    61  
    62  ```
    63  resource "openstack_compute_instance_v2" "boot-from-volume" {
    64    name = "boot-from-volume"
    65    flavor_id = "3"
    66    key_pair = "my_key_pair_name"
    67    security_groups = ["default"]
    68  
    69    block_device {
    70      uuid = "<image-id>"
    71      source_type = "image"
    72      volume_size = 5
    73      boot_index = 0
    74      destination_type = "volume"
    75      delete_on_termination = true
    76    }
    77  
    78    network {
    79      name = "my_network"
    80    }
    81  }
    82  ```
    83  
    84  ### Boot From an Existing Volume
    85  
    86  ```
    87  resource "openstack_blockstorage_volume_v1" "myvol" {
    88    name = "myvol"
    89    size = 5
    90    image_id = "<image-id>"
    91  }
    92  
    93  resource "openstack_compute_instance_v2" "boot-from-volume" {
    94    name = "bootfromvolume"
    95    flavor_id = "3"
    96    key_pair = "my_key_pair_name"
    97    security_groups = ["default"]
    98  
    99    block_device {
   100      uuid = "${openstack_blockstorage_volume_v1.myvol.id}"
   101      source_type = "volume"
   102      boot_index = 0
   103      destination_type = "volume"
   104      delete_on_termination = true
   105    }
   106  
   107    network {
   108      name = "my_network"
   109    }
   110  }
   111  ```
   112  
   113  ### Instance With Multiple Networks
   114  
   115  ```
   116  resource "openstack_compute_floatingip_v2" "myip" {
   117    pool = "my_pool"
   118  }
   119  
   120  resource "openstack_compute_instance_v2" "multi-net" {
   121    name = "multi-net"
   122    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
   123    flavor_id = "3"
   124    key_pair = "my_key_pair_name"
   125    security_groups = ["default"]
   126  
   127    network {
   128      name = "my_first_network"
   129    }
   130  
   131    network {
   132      name = "my_second_network"
   133      floating_ip = "${openstack_compute_floatingip_v2.myip.address}"
   134      # Terraform will use this network for provisioning
   135      access_network = true
   136    }
   137  }
   138  ```
   139  
   140  ### Instance With Personality
   141  
   142  ```
   143  resource "openstack_compute_instance_v2" "personality" {
   144    name = "personality"
   145    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
   146    flavor_id = "3"
   147    key_pair = "my_key_pair_name"
   148    security_groups = ["default"]
   149  
   150    personality {
   151      file = "/path/to/file/on/instance.txt
   152      content = "contents of file"
   153    }
   154  
   155    network {
   156      name = "my_network"
   157    }
   158  }
   159  ```
   160  
   161  ### Instance with Multiple Ephemeral Disks
   162  
   163  ```
   164  resource "openstack_compute_instance_v2" "multi-eph" {
   165    name = "multi_eph"
   166    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
   167    flavor_id = "3"
   168    key_pair = "my_key_pair_name"
   169    security_groups = ["default"]
   170  
   171    block_device {
   172      boot_index = 0
   173      delete_on_termination = true
   174      destination_type = "local"
   175      source_type = "image"
   176      uuid = "<image-id>"
   177    }
   178  
   179    block_device {
   180      boot_index = -1
   181      delete_on_termination = true
   182      destination_type = "local"
   183      source_type = "blank"
   184      volume_size = 1
   185    }
   186  
   187    block_device {
   188      boot_index = -1
   189      delete_on_termination = true
   190      destination_type = "local"
   191      source_type = "blank"
   192      volume_size = 1
   193    }
   194  }
   195  ```
   196  
   197  ## Argument Reference
   198  
   199  The following arguments are supported:
   200  
   201  * `region` - (Required) The region in which to create the server instance. If
   202      omitted, the `OS_REGION_NAME` environment variable is used. Changing this
   203      creates a new server.
   204  
   205  * `name` - (Required) A unique name for the resource.
   206  
   207  * `image_id` - (Optional; Required if `image_name` is empty and not booting
   208      from a volume. Do not specify if booting from a volume.) The image ID of
   209      the desired image for the server. Changing this creates a new server.
   210  
   211  * `image_name` - (Optional; Required if `image_id` is empty and not booting
   212      from a volume. Do not specify if booting from a volume.) The name of the
   213      desired image for the server. Changing this creates a new server.
   214  
   215  * `flavor_id` - (Optional; Required if `flavor_name` is empty) The flavor ID of
   216      the desired flavor for the server. Changing this resizes the existing server.
   217  
   218  * `flavor_name` - (Optional; Required if `flavor_id` is empty) The name of the
   219      desired flavor for the server. Changing this resizes the existing server.
   220  
   221  * `floating_ip` - (Optional) A *Compute* Floating IP that will be associated
   222      with the Instance. The Floating IP must be provisioned already. See *Notes*
   223      for more information about Floating IPs.
   224  
   225  * `user_data` - (Optional) The user data to provide when launching the instance.
   226      Changing this creates a new server.
   227  
   228  * `security_groups` - (Optional) An array of one or more security group names
   229      to associate with the server. Changing this results in adding/removing
   230      security groups from the existing server.
   231  
   232  * `availability_zone` - (Optional) The availability zone in which to create
   233      the server. Changing this creates a new server.
   234  
   235  * `network` - (Optional) An array of one or more networks to attach to the
   236      instance. The network object structure is documented below. Changing this
   237      creates a new server.
   238  
   239  * `metadata` - (Optional) Metadata key/value pairs to make available from
   240      within the instance. Changing this updates the existing server metadata.
   241  
   242  * `config_drive` - (Optional) Whether to use the config_drive feature to
   243      configure the instance. Changing this creates a new server.
   244  
   245  * `admin_pass` - (Optional) The administrative password to assign to the server.
   246      Changing this changes the root password on the existing server.
   247  
   248  * `key_pair` - (Optional) The name of a key pair to put on the server. The key
   249      pair must already be created and associated with the tenant's account.
   250      Changing this creates a new server.
   251  
   252  * `block_device` - (Optional) The object for booting by volume. The block_device
   253      object structure is documented below. Changing this creates a new server.
   254      You can specify multiple block devices which will create an instance with
   255      multiple ephemeral (local) disks.
   256  
   257  * `volume` - (Optional) Attach an existing volume to the instance. The volume
   258      structure is described below.
   259  
   260  * `scheduler_hints` - (Optional) Provide the Nova scheduler with hints on how
   261      the instance should be launched. The available hints are described below.
   262  
   263  * `personality` - (Optional) Customize the personality of an instance by
   264      defining one or more files and their contents. The personality structure
   265      is described below.
   266  
   267  * `stop_before_destroy` - (Optional) Whether to try stop instance gracefully
   268      before destroying it, thus giving chance for guest OS daemons to stop correctly.
   269      If instance doesn't stop within timeout, it will be destroyed anyway.
   270  
   271  
   272  The `network` block supports:
   273  
   274  * `uuid` - (Required unless `port`  or `name` is provided) The network UUID to
   275      attach to the server. Changing this creates a new server.
   276  
   277  * `name` - (Required unless `uuid` or `port` is provided) The human-readable
   278      name of the network. Changing this creates a new server.
   279  
   280  * `port` - (Required unless `uuid` or `name` is provided) The port UUID of a
   281      network to attach to the server. Changing this creates a new server.
   282  
   283  * `fixed_ip_v4` - (Optional) Specifies a fixed IPv4 address to be used on this
   284      network. Changing this creates a new server.
   285  
   286  * `fixed_ip_v6` - (Optional) Specifies a fixed IPv6 address to be used on this
   287      network. Changing this creates a new server.
   288  
   289  * `floating_ip` - (Optional) Specifies a floating IP address to be associated
   290      with this network. Cannot be combined with a top-level floating IP. See
   291      *Notes* for more information about Floating IPs.
   292  
   293  * `access_network` - (Optional) Specifies if this network should be used for
   294      provisioning access. Accepts true or false. Defaults to false.
   295  
   296  The `block_device` block supports:
   297  
   298  * `uuid` - (Required unless `source_type` is set to `"blank"` ) The UUID of
   299      the image, volume, or snapshot. Changing this creates a new server.
   300  
   301  * `source_type` - (Required) The source type of the device. Must be one of
   302      "blank", "image", "volume", or "snapshot". Changing this creates a new
   303      server.
   304  
   305  * `volume_size` - The size of the volume to create (in gigabytes). Required
   306      in the following combinations: source=image and destination=volume,
   307      source=blank and destination=local. Changing this creates a new server.
   308  
   309  * `boot_index` - (Optional) The boot index of the volume. It defaults to 0.
   310      Changing this creates a new server.
   311  
   312  * `destination_type` - (Optional) The type that gets created. Possible values
   313      are "volume" and "local". Changing this creates a new server.
   314  
   315  * `delete_on_termination` - (Optional) Delete the volume / block device upon
   316      termination of the instance. Defaults to false. Changing this creates a
   317      new server.
   318  
   319  The `volume` block supports:
   320  
   321  * `volume_id` - (Required) The UUID of the volume to attach.
   322  
   323  * `device` - (Optional) The device that the volume will be attached as. For
   324      example:  `/dev/vdc`. Omit this option to allow the volume to be
   325      auto-assigned a device.
   326  
   327  The `scheduler_hints` block supports:
   328  
   329  * `group` - (Optional) A UUID of a Server Group. The instance will be placed
   330      into that group.
   331  
   332  * `different_host` - (Optional) A list of instance UUIDs. The instance will
   333      be scheduled on a different host than all other instances.
   334  
   335  * `same_host` - (Optional) A list of instance UUIDs. The instance will be
   336      scheduled on the same host of those specified.
   337  
   338  * `query` - (Optional) A conditional query that a compute node must pass in
   339      order to host an instance.
   340  
   341  * `target_cell` - (Optional) The name of a cell to host the instance.
   342  
   343  * `build_near_host_ip` - (Optional) An IP Address in CIDR form. The instance
   344      will be placed on a compute node that is in the same subnet.
   345  
   346  The `personality` block supports:
   347  
   348  * `file` - (Required) The absolute path of the destination file.
   349  
   350  * `contents` - (Required) The contents of the file. Limited to 255 bytes.
   351  
   352  ## Attributes Reference
   353  
   354  The following attributes are exported:
   355  
   356  * `region` - See Argument Reference above.
   357  * `name` - See Argument Reference above.
   358  * `access_ip_v4` - The first detected Fixed IPv4 address _or_ the
   359      Floating IP.
   360  * `access_ip_v6` - The first detected Fixed IPv6 address.
   361  * `metadata` - See Argument Reference above.
   362  * `security_groups` - See Argument Reference above.
   363  * `flavor_id` - See Argument Reference above.
   364  * `flavor_name` - See Argument Reference above.
   365  * `network/uuid` - See Argument Reference above.
   366  * `network/name` - See Argument Reference above.
   367  * `network/port` - See Argument Reference above.
   368  * `network/fixed_ip_v4` - The Fixed IPv4 address of the Instance on that
   369      network.
   370  * `network/fixed_ip_v6` - The Fixed IPv6 address of the Instance on that
   371      network.
   372  * `network/floating_ip` - The Floating IP address of the Instance on that
   373      network.
   374  * `network/mac` - The MAC address of the NIC on that network.
   375  
   376  ## Notes
   377  
   378  ### Floating IPs
   379  
   380  Floating IPs can be associated in one of two ways:
   381  
   382  * You can specify a Floating IP address by using the top-level `floating_ip`
   383  attribute. This floating IP will be associated with either the network defined
   384  in the first `network` block or the default network if no `network` blocks are
   385  defined.
   386  
   387  * You can specify a Floating IP address by using the `floating_ip` attribute
   388  defined in the `network` block. Each `network` block can have its own floating
   389  IP address.
   390  
   391  Only one of the above methods can be used.
   392  
   393  ### Multiple Ephemeral Disks
   394  
   395  It's possible to specify multiple `block_device` entries to create an instance
   396  with multiple ephemeral (local) disks. In order to create multiple ephemeral
   397  disks, the sum of the total amount of ephemeral space must be less than or
   398  equal to what the chosen flavor supports.
   399  
   400  The following example shows how to create an instance with multiple ephemeral
   401  disks:
   402  
   403  ```
   404  resource "openstack_compute_instance_v2" "foo" {
   405    name = "terraform-test"
   406    security_groups = ["default"]
   407  
   408    block_device {
   409      boot_index = 0
   410      delete_on_termination = true
   411      destination_type = "local"
   412      source_type = "image"
   413      uuid = "<image uuid>"
   414    }
   415  
   416    block_device {
   417      boot_index = -1
   418      delete_on_termination = true
   419      destination_type = "local"
   420      source_type = "blank"
   421      volume_size = 1
   422    }
   423  
   424    block_device {
   425      boot_index = -1
   426      delete_on_termination = true
   427      destination_type = "local"
   428      source_type = "blank"
   429      volume_size = 1
   430    }
   431  }
   432  ```