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

     1  ---
     2  layout: "opc"
     3  page_title: "Oracle: opc_compute_instance"
     4  sidebar_current: "docs-opc-resource-instance"
     5  description: |-
     6    Creates and manages an instance in an OPC identity domain.
     7  ---
     8  
     9  # opc\_compute\_instance
    10  
    11  The ``opc_compute_instance`` resource creates and manages an instance in an OPC identity domain.
    12  
    13  ~> **Caution:** The ``opc_compute_instance`` resource can completely delete your
    14  instance just as easily as it can create it. To avoid costly accidents,
    15  consider setting
    16  [``prevent_destroy``](/docs/configuration/resources.html#prevent_destroy)
    17  on your instance resources as an extra safety measure.
    18  
    19  ## Example Usage
    20  
    21  ```hcl
    22  resource "opc_compute_ip_network" "test" {
    23    name                = "internal-network"
    24    description         = "Terraform Provisioned Internal Network"
    25    ip_address_prefix   = "10.0.1.0/24"
    26    public_napt_enabled = false
    27  }
    28  
    29  resource "opc_compute_storage_volume" "test" {
    30    name = "internal"
    31    size = 100
    32  }
    33  
    34  resource "opc_compute_instance" "test" {
    35    name       = "instance1"
    36    label      = "Terraform Provisioned Instance"
    37    shape      = "oc3"
    38    image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300"
    39  
    40    storage {
    41      volume = "${opc_compute_storage_volume.test.name}"
    42      index  = 1
    43    }
    44  
    45    networking_info {
    46      index          = 0
    47      nat            = ["ippool:/oracle/public/ippool"]
    48      shared_network = true
    49    }
    50  }
    51  
    52  ```
    53  
    54  ## Argument Reference
    55  
    56  The following arguments are supported:
    57  
    58  * `name` - (Required) The name of the instance.
    59  
    60  * `shape` - (Required) The shape of the instance, e.g. `oc4`.
    61  
    62  * `instance_attributes` - (Optional) A JSON string of custom attributes. See [Attributes](#attributes) below for more information.
    63  
    64  * `boot_order` - (Optional) The index number of the bootable storage volume, presented as a list, that should be used to boot the instance. The only valid value is `[1]`. If you set this attribute, you must also specify a bootable storage volume with index number 1 in the volume sub-parameter of storage_attachments. When you specify boot_order, you don't need to specify the imagelist attribute, because the instance is booted using the image on the specified bootable storage volume. If you specify both boot_order and imagelist, the imagelist attribute is ignored.
    65  
    66  * `hostname` - (Optional) The host name assigned to the instance. On an Oracle Linux instance, this host name is displayed in response to the hostname command. Only relative DNS is supported. The domain name is suffixed to the host name that you specify. The host name must not end with a period. If you don't specify a host name, then a name is generated automatically.
    67  
    68  * `image_list` - (Optional) The imageList of the instance, e.g. `/oracle/public/oel_6.4_2GB_v1`.
    69  
    70  * `label` - (Optional) The label to apply to the instance.
    71  
    72  * `networking_info` - (Optional) Information pertaining to an individual network interface to be created and attached to the instance. See [Networking Info](#networking-info) below for more information.
    73  
    74  * `storage` - (Optional) Information pertaining to an individual storage attachment to be created during instance creation. Please see [Storage Attachments](#storage-attachments) below for more information.
    75  
    76  * `reverse_dns` - (Optional) If set to `true` (default), then reverse DNS records are created. If set to `false`, no reverse DNS records are created.
    77  
    78  * `ssh_keys` - (Optional) A list of the names of the SSH Keys that can be used to log into the instance.  
    79  
    80  * `tags` - (Optional) A list of strings that should be supplied to the instance as tags.
    81  
    82  ## Attributes
    83  
    84  During instance creation, there are several custom attributes that a user may wish to make available to the instance during instance creation.
    85  These attributes can be specified via the `instance_attributes` field, and must be presented as a string in JSON format.
    86  The easiest way to populate this field is with a HEREDOC:
    87  
    88  ```hcl
    89  resource "opc_compute_instance" "foo" {
    90    name = "test"
    91    label = "test"
    92    shape = "oc3"
    93    imageList = "/oracle/public/oel_6.4_2GB_v1"
    94    instance_attributes = <<JSON
    95  {
    96    "foo": "bar",
    97    "baz": 42,
    98    "my_obj": {
    99      "my_key": false,
   100      "another": true
   101    }
   102  }
   103  JSON
   104  
   105    sshKeys = ["${opc_compute_ssh_key.key1.name}"]
   106  }
   107  ```
   108  
   109  This allows the user to have full control over the attributes supplied to an instance during instance creation.
   110  There are, as well, some attributes that get populated during instance creation, and the full attributes map can be seen
   111  via the exported `attributes` attribute.
   112  
   113  **Warning:** Due to how Terraform imports resources, the `instance_attributes` field will _only_ be populated
   114  when creating a new instance _with terraform_. This requires us to ignore any state diffs on changes to the `instance_attributes` field.
   115  Thus, any configuration changes in the `instance_attributes` field, will not register a diff during a `plan` or `apply`.
   116   If a user wishes to make a change solely to the supplied instance attributes, and recreate the instance resource, `terraform taint` is the best solution.
   117   You can read more about the `taint` command [here](https://www.terraform.io/docs/commands/taint.html)
   118  
   119  ## Networking Info
   120  
   121  Each `networking_info` config manages a single network interface for the instance.
   122  The attributes are either required or optional depending on whether or not the interface is
   123  in the Shared Network, or an IP Network. Some attributes can only be used if the interface is in the Shared
   124   Network, and same for an interface in an IP Network.
   125  
   126  The following attributes are supported:
   127  
   128  * `index` - (Required) The numerical index of the network interface. Specified as an integer to allow for use of `count`, but directly maps to `ethX`. ie: With `index` set to `0`, the interface `eth0` will be created. Can only be `0-9`.
   129  * `dns` - (Optional) Array of DNS servers for the interface.
   130  * `ip_address` - (Optional, IP Network Only) IP Address assigned to the interface.
   131  * `ip_network` - (Optional, IP Network Only) The IP Network assigned to the interface.
   132  * `mac_address` - (Optional, IP Network Only) The MAC address of the interface.
   133  * `model` - (Required, Shared Network Only) The model of the NIC card used. Must be set to `e1000`.
   134  * `name_servers` - (Optional) Array of name servers for the interface.
   135  * `nat` - (Optional for IP Networks, Required for the Shared Network) The IP Reservations associated with the interface (IP Network).
   136   Indicates whether a temporary or permanent public IP address should be assigned to the instance (Shared Network).
   137  * `search_domains` - (Optional) The search domains that are sent through DHCP as option 119.
   138  * `sec_lists` - (Optional, Shared Network Only) The security lists the interface is added to.
   139  * `shared_network` - (Required) Whether or not the interface is inside the Shared Network or an IP Network.
   140  * `vnic` - (Optional, IP Network Only) The name of the vNIC created for the IP Network.
   141  * `vnic_sets` - (Optional, IP Network Only) The array of vNIC Sets the interface was added to.
   142  
   143  ## Storage Attachments
   144  
   145  Each Storage Attachment config manages a single storage attachment that is created _during instance creation_.
   146  This means that any storage attachments created during instance creation cannot be detached from the instance.
   147  Use the `resource_storage_attachment` resource to manage storage attachments for instances if you wish to detach the
   148  storage volumes at a later date.
   149  
   150  The following attributes are supported:
   151  
   152  * `index` - (Required) The Index number of the volume attachment. `1` is the boot volume for the instance. Values `1-10` allowed.
   153  * `volume` - (Required) The name of the storage volume to attach to the instance.
   154  
   155  In addition to the above attributes, the following attributes are exported for a storage volume
   156  
   157  * `name` - Name of the storage volume attachment.
   158  
   159  ## Attributes Reference
   160  
   161  In addition to the attributes listed above, the following attributes are exported:
   162  
   163  * `id` - The `id` of the instance.
   164  * `attributes` - The full attributes of the instance, as a JSON string.
   165  * `availability_domain` - The availability domain the instance is in.
   166  * `domain` - The default domain to use for the hostname and for DNS lookups.
   167  * `entry` - Imagelist entry number.
   168  * `fingerprint` - SSH server fingerprint presented by the instance.
   169  * `image_format` - The format of the image.
   170  * `ip_address` - The IP Address of the instance.
   171  * `placement_requirements` - The array of placement requirements for the instance.
   172  * `platform` - The OS Platform of the instance.
   173  * `priority` - The priority at which the instance was ran.
   174  * `quota_reservation` - Reference to the QuotaReservation, to be destroyed with the instance.
   175  * `relationships` - The array of relationship specifications to be satisfied on instance placement.
   176  * `resolvers` - Array of resolvers to be used instead of the default resolvers.
   177  * `site` - The site the instance is running on.
   178  * `start_time` - The launch time of the instance.
   179  * `state` - The instance's state.
   180  * `vcable_id` - vCable ID for the instance.
   181  * `virtio` - Boolean that determines if the instance is a virtio device.
   182  * `vnc_address` - The VNC address and port of the instance.
   183  
   184  ## Import
   185  
   186  Instances can be imported using the Instance's combined `Name` and `ID` with a `/` character separating them.
   187  If viewing an instance in the Oracle Web Console, the instance's `name` and `id` are the last two fields in the instances fully qualified `Name`
   188  
   189  For example, in the Web Console an instance's fully qualified name is:
   190  ```
   191  /Compute-<identify>/<user>@<account>/<instance_name>/<instance_id>
   192  ```
   193  
   194  The instance can be imported as such:
   195  
   196  ```shell
   197  $ terraform import opc_compute_instance.instance1 instance_name/instance_id
   198  ```