# 

# exoscale_compute_instance (Resource)

Manage Exoscale [Compute Instances](https://community.exoscale.com/documentation/compute/).

Corresponding data sources: [exoscale_compute_instance](../data-sources/compute_instance.md), [exoscale_compute_instance_list]({{< ref "../data-sources/compute_instance_list.md" >}}).

After the creation, you can retrieve the password of an instance with [Exoscale CLI](https://github.com/exoscale/cli): `exo compute instance reveal-password NAME`.

## Example Usage

```terraform
data "exoscale_template" "my_template" {
  zone = "ch-gva-2"
  name = "Linux Ubuntu 22.04 LTS 64-bit"
}

resource "exoscale_compute_instance" "my_instance" {
  zone = "ch-gva-2"
  name = "my-instance"

  template_id = data.exoscale_template.my_template.id
  type        = "standard.medium"
  disk_size   = 10
}
```

Please refer to the [examples](https://github.com/exoscale/terraform-provider-exoscale/tree/master/examples/)
directory for complete configuration examples.

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `disk_size` (Number) The instance disk size (GiB; at least `10`). Can not be decreased after creation. **WARNING**: updating this attribute stops/restarts the instance.
- `name` (String) The compute instance name.
- `template_id` (String) ❗ The [exoscale_template]({{< ref "../data-sources/template.md" >}}) (ID) to use when creating the instance.
- `type` (String) The instance type (`<family>.<size>`, e.g. `standard.medium`; use the [Exoscale CLI](https://github.com/exoscale/cli/) - `exo compute instance-type list` - for the list of available types). **WARNING**: updating this attribute stops/restarts the instance.
- `zone` (String) ❗ The Exoscale [Zone](https://www.exoscale.com/datacenters/) name.

### Optional

- `anti_affinity_group_ids` (Set of String) ❗ A list of [exoscale_anti_affinity_group]({{< ref "./anti_affinity_group.md" >}}) (IDs) to attach to the instance (may only be set at creation time).
- `block_storage_volume_ids` (Set of String) A list of [exoscale_block_storage_volume]({{< ref "./block_storage_volume.md" >}}) (ID) to attach to the instance.
- `deploy_target_id` (String) ❗ A deploy target ID.
- `destroy_protected` (Boolean) Mark the instance as protected, the Exoscale API will refuse to delete the instance until the protection is removed (boolean; default: `false`).
- `elastic_ip_ids` (Set of String) A list of [exoscale_elastic_ip]({{< ref "./elastic_ip.md" >}}) (IDs) to attach to the instance.
- `enable_secure_boot` (Boolean) ❗ Enable secure boot on the instance (boolean; default: `false`). Can not be changed after the creation.
- `enable_tpm` (Boolean) Enable TPM on the instance (boolean; default: `false`). Can not be disabled after the creation. **WARNING**: enabling this attribute stops/restarts the instance.
- `ipv6` (Boolean) Enable IPv6 on the instance (boolean; default: `false`).
- `labels` (Map of String) A map of key/value labels.
- `network_interface` (Block Set) Private network interfaces (may be specified multiple times). Structure is documented below. (see [below for nested schema](#nestedblock--network_interface))
- `private` (Boolean) Whether the instance is private (no public IP addresses; default: false)
- `reverse_dns` (String) Domain name for reverse DNS record.
- `security_group_ids` (Set of String) A list of [exoscale_security_group]({{< ref "./security_group.md" >}}) (IDs) to attach to the instance.
- `ssh_key` (String, Deprecated) ❗ The [exoscale_ssh_key]({{< ref "./ssh_key.md" >}}) (name) to authorize in the instance (may only be set at creation time).
- `ssh_keys` (Set of String) ❗ The list of [exoscale_ssh_key]({{< ref "./ssh_key.md" >}}) (name) to authorize in the instance (may only be set at creation time).
- `state` (String) The instance state (`running` or `stopped`). If omitted, instance will start and reach `running` state.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `user_data` (String) [cloud-init](https://cloudinit.readthedocs.io/) configuration.

### Read-Only

- `created_at` (String) The instance creation date.
- `id` (String) The ID of this resource.
- `ipv6_address` (String) The instance (main network interface) IPv6 address (if enabled).
- `mac_address` (String) MAC address
- `private_network_ids` (Set of String, Deprecated) A list of private networks (IDs) attached to the instance. Please use the `network_interface.*.network_id` argument instead.
- `public_ip_address` (String) The instance (main network interface) IPv4 address.

<a id="nestedblock--network_interface"></a>
### Nested Schema for `network_interface`

Required:

- `network_id` (String) The [exoscale_private_network]({{< ref "./private_network.md" >}}) (ID) to attach to the instance.

Optional:

- `ip_address` (String) The IPv4 address to request as static DHCP lease if the network interface is attached to a *managed* private network.

Read-Only:

- `mac_address` (String) MAC address


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)
- `read` (String)
- `update` (String)

-> The symbol ❗ in an attribute indicates that modifying it, will force the creation of a new resource.

## Import

```shell
# An existing compute instance may be imported by `<ID>@<zone>`:

terraform import \
  exoscale_compute_instance.my_instance \
  f81d4fae-7dec-11d0-a765-00a0c91e6bf6@ch-gva-2
```

