--- layout: "opc" page_title: "Oracle: opc_compute_instance" sidebar_current: "docs-opc-resource-instance" description: |- Creates and manages an instance in an OPC identity domain. --- # opc\_compute\_instance The ``opc_compute_instance`` resource creates and manages an instance in an OPC identity domain. ~> **Caution:** The ``opc_compute_instance`` resource can completely delete your instance just as easily as it can create it. To avoid costly accidents, consider setting [``prevent_destroy``](/docs/configuration/resources.html#prevent_destroy) on your instance resources as an extra safety measure. ## Example Usage ```hcl resource "opc_compute_ip_network" "test" { name = "internal-network" description = "Terraform Provisioned Internal Network" ip_address_prefix = "10.0.1.0/24" public_napt_enabled = false } resource "opc_compute_storage_volume" "test" { name = "internal" size = 100 } resource "opc_compute_instance" "test" { name = "instance1" label = "Terraform Provisioned Instance" shape = "oc3" image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300" storage { volume = "${opc_compute_storage_volume.test.name}" index = 1 } networking_info { index = 0 nat = ["ippool:/oracle/public/ippool"] shared_network = true } } ``` ## Argument Reference The following arguments are supported: * `name` - (Required) The name of the instance. * `shape` - (Required) The shape of the instance, e.g. `oc4`. * `instance_attributes` - (Optional) A JSON string of custom attributes. See [Attributes](#attributes) below for more information. * `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. * `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. * `image_list` - (Optional) The imageList of the instance, e.g. `/oracle/public/oel_6.4_2GB_v1`. * `label` - (Optional) The label to apply to the instance. * `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. * `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. * `reverse_dns` - (Optional) If set to `true` (default), then reverse DNS records are created. If set to `false`, no reverse DNS records are created. * `ssh_keys` - (Optional) A list of the names of the SSH Keys that can be used to log into the instance. * `tags` - (Optional) A list of strings that should be supplied to the instance as tags. ## Attributes During instance creation, there are several custom attributes that a user may wish to make available to the instance during instance creation. These attributes can be specified via the `instance_attributes` field, and must be presented as a string in JSON format. The easiest way to populate this field is with a HEREDOC: ```hcl resource "opc_compute_instance" "foo" { name = "test" label = "test" shape = "oc3" imageList = "/oracle/public/oel_6.4_2GB_v1" instance_attributes = </@// ``` The instance can be imported as such: ```shell $ terraform import opc_compute_instance.instance1 instance_name/instance_id ```