github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/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  ```
    16  resource "openstack_compute_instance_v2" "test-server" {
    17    name = "tf-test"
    18    image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
    19    flavor_id = "3"
    20    metadata {
    21      this = "that"
    22    }
    23    key_pair = "my_key_pair_name"
    24    security_groups = ["test-group-1"]
    25  }
    26  ```
    27  
    28  ## Argument Reference
    29  
    30  The following arguments are supported:
    31  
    32  * `region` - (Required) The region in which to create the server instance. If
    33      omitted, the `OS_REGION_NAME` environment variable is used. Changing this
    34      creates a new server.
    35  
    36  * `name` - (Required) A unique name for the resource.
    37  
    38  * `image_id` - (Optional; Required if `image_name` is empty and not booting
    39      from a volume) The image ID of the desired image for the server. Changing
    40      this creates a new server.
    41  
    42  * `image_name` - (Optional; Required if `image_id` is empty and not booting
    43      from a volume) The name of the desired image for the server. Changing this
    44      creates a new server.
    45  
    46  * `flavor_id` - (Optional; Required if `flavor_name` is empty) The flavor ID of
    47      the desired flavor for the server. Changing this resizes the existing server.
    48  
    49  * `flavor_name` - (Optional; Required if `flavor_id` is empty) The name of the
    50      desired flavor for the server. Changing this resizes the existing server.
    51  
    52  * `floating_ip` - (Optional) A *Compute* Floating IP that will be associated
    53      with the Instance. The Floating IP must be provisioned already. See *Notes*
    54      for more information about Floating IPs.
    55  
    56  * `user_data` - (Optional) The user data to provide when launching the instance.
    57      Changing this creates a new server.
    58  
    59  * `security_groups` - (Optional) An array of one or more security group names
    60      to associate with the server. Changing this results in adding/removing
    61      security groups from the existing server.
    62  
    63  * `availability_zone` - (Optional) The availability zone in which to create
    64      the server. Changing this creates a new server.
    65  
    66  * `network` - (Optional) An array of one or more networks to attach to the
    67      instance. The network object structure is documented below. Changing this
    68      creates a new server.
    69  
    70  * `metadata` - (Optional) Metadata key/value pairs to make available from
    71      within the instance. Changing this updates the existing server metadata.
    72  
    73  * `config_drive` - (Optional) Whether to use the config_drive feature to
    74      configure the instance. Changing this creates a new server.
    75  
    76  * `admin_pass` - (Optional) The administrative password to assign to the server.
    77      Changing this changes the root password on the existing server.
    78  
    79  * `key_pair` - (Optional) The name of a key pair to put on the server. The key
    80      pair must already be created and associated with the tenant's account.
    81      Changing this creates a new server.
    82  
    83  * `block_device` - (Optional) The object for booting by volume. The block_device
    84      object structure is documented below. Changing this creates a new server.
    85      You can specify multiple block devices which will create an instance with
    86      multiple ephemeral (local) disks.
    87  
    88  * `volume` - (Optional) Attach an existing volume to the instance. The volume
    89      structure is described below.
    90  
    91  * `scheduler_hints` - (Optional) Provide the Nova scheduler with hints on how
    92      the instance should be launched. The available hints are described below.
    93  
    94  * `personality` - (Optional) Customize the personality of an instance by
    95      defining one or more files and their contents. The personality structure
    96      is described below.
    97  
    98  The `network` block supports:
    99  
   100  * `uuid` - (Required unless `port`  or `name` is provided) The network UUID to
   101      attach to the server.
   102  
   103  * `name` - (Required unless `uuid` or `port` is provided) The human-readable
   104      name of the network.
   105  
   106  * `port` - (Required unless `uuid` or `name` is provided) The port UUID of a
   107      network to attach to the server.
   108  
   109  * `fixed_ip_v4` - (Optional) Specifies a fixed IPv4 address to be used on this
   110      network.
   111  
   112  * `floating_ip` - (Optional) Specifies a floating IP address to be associated
   113      with this network. Cannot be combined with a top-level floating IP. See
   114      *Notes* for more information about Floating IPs.
   115  
   116  * `access_network` - (Optional) Specifies if this network should be used for
   117      provisioning access. Accepts true or false. Defaults to false.
   118  
   119  The `block_device` block supports:
   120  
   121  * `uuid` - (Required unless `source_type` is set to `"blank"` ) The UUID of the image, volume, or snapshot.
   122  
   123  * `source_type` - (Required) The source type of the device. Must be one of
   124      "blank", "image", "volume", or "snapshot".
   125  
   126  * `volume_size` - The size of the volume to create (in gigabytes). Required
   127      in the following combinations: source=image and destination=volume,
   128      source=blank and destination=local.
   129  
   130  * `boot_index` - (Optional) The boot index of the volume. It defaults to 0.
   131  
   132  * `destination_type` - (Optional) The type that gets created. Possible values
   133      are "volume" and "local".
   134  
   135  The `volume` block supports:
   136  
   137  * `volume_id` - (Required) The UUID of the volume to attach.
   138  
   139  * `device` - (Optional) The device that the volume will be attached as. For
   140      example:  `/dev/vdc`. Omit this option to allow the volume to be
   141      auto-assigned a device.
   142  
   143  The `scheduler_hints` block supports:
   144  
   145  * `group` - (Optional) A UUID of a Server Group. The instance will be placed
   146      into that group.
   147  
   148  * `different_host` - (Optional) A list of instance UUIDs. The instance will
   149      be scheduled on a different host than all other instances.
   150  
   151  * `same_host` - (Optional) A list of instance UUIDs. The instance will be
   152      scheduled on the same host of those specified.
   153  
   154  * `query` - (Optional) A conditional query that a compute node must pass in
   155      order to host an instance.
   156  
   157  * `target_cell` - (Optional) The name of a cell to host the instance.
   158  
   159  * `build_near_host_ip` - (Optional) An IP Address in CIDR form. The instance
   160      will be placed on a compute node that is in the same subnet.
   161  
   162  The `personality` block supports:
   163  
   164  * `file` - (Required) The absolute path of the destination file.
   165  
   166  * `contents` - (Required) The contents of the file. Limited to 255 bytes.
   167  
   168  ## Attributes Reference
   169  
   170  The following attributes are exported:
   171  
   172  * `region` - See Argument Reference above.
   173  * `name` - See Argument Reference above.
   174  * `access_ip_v4` - The first detected Fixed IPv4 address _or_ the
   175      Floating IP.
   176  * `access_ip_v6` - The first detected Fixed IPv6 address.
   177  * `metadata` - See Argument Reference above.
   178  * `security_groups` - See Argument Reference above.
   179  * `flavor_id` - See Argument Reference above.
   180  * `flavor_name` - See Argument Reference above.
   181  * `network/uuid` - See Argument Reference above.
   182  * `network/name` - See Argument Reference above.
   183  * `network/port` - See Argument Reference above.
   184  * `network/fixed_ip_v4` - The Fixed IPv4 address of the Instance on that
   185      network.
   186  * `network/fixed_ip_v6` - The Fixed IPv6 address of the Instance on that
   187      network.
   188  * `network/floating_ip` - The Floating IP address of the Instance on that
   189      network.
   190  * `network/mac` - The MAC address of the NIC on that network.
   191  
   192  ## Notes
   193  
   194  ### Floating IPs
   195  
   196  Floating IPs can be associated in one of two ways:
   197  
   198  * You can specify a Floating IP address by using the top-level `floating_ip`
   199  attribute. This floating IP will be associated with either the network defined
   200  in the first `network` block or the default network if no `network` blocks are
   201  defined.
   202  
   203  * You can specify a Floating IP address by using the `floating_ip` attribute
   204  defined in the `network` block. Each `network` block can have its own floating
   205  IP address.
   206  
   207  Only one of the above methods can be used.
   208  
   209  ### Multiple Ephemeral Disks
   210  
   211  It's possible to specify multiple `block_device` entries to create an instance
   212  with multiple ephemeral (local) disks. In order to create multiple ephemeral
   213  disks, the sum of the total amount of ephemeral space must be less than or
   214  equal to what the chosen flavor supports.
   215  
   216  The following example shows how to create an instance with multiple ephemeral
   217  disks:
   218  
   219  ```
   220  resource "openstack_compute_instance_v2" "foo" {
   221    name = "terraform-test"
   222    security_groups = ["default"]
   223  
   224    block_device {
   225      boot_index = 0
   226      delete_on_termination = true
   227      destination_type = "local"
   228      source_type = "image"
   229      uuid = "<image uuid>"
   230    }
   231  
   232    block_device {
   233      boot_index = -1
   234      delete_on_termination = true
   235      destination_type = "local"
   236      source_type = "blank"
   237      volume_size = 1
   238    }
   239  
   240    block_device {
   241      boot_index = -1
   242      delete_on_termination = true
   243      destination_type = "local"
   244      source_type = "blank"
   245      volume_size = 1
   246    }
   247  }
   248  ```