# ionoscloud\_cube\_server

A [Cube](https://docs.ionos.com/cloud/compute-services/cubes/overview) is a Virtual Machine (VM) with an attached NVMe Volume. You can use each newly created Cube as a new VM, either standalone or in combination with other IONOS CLOUD products.

Check out [Configuration templates](https://docs.ionos.com/cloud/compute-services/cubes/overview#basic-cubes)

## Example Usage

This resource will create an operational server. After this section completes, the provisioner can be called.

### CUBE Server

```hcl
data "ionoscloud_template" "example" {
    name            = "Basic Cube XS"
}

resource "ionoscloud_datacenter" "example" {
	name            = "Datacenter Example"
	location        = "de/txl"
}

resource "ionoscloud_lan" "example" {
  datacenter_id     = ionoscloud_datacenter.example.id
  public            = true
  name              = "Lan Example"
}

resource "ionoscloud_cube_server" "example" {
  name              = "Server Example"
  image_name        = "ubuntu:latest"
  template_uuid     = data.ionoscloud_template.example.id
  image_password    = random_password.server_image_password.result
  datacenter_id     = ionoscloud_datacenter.example.id
  volume {
    name            = "Volume Example"
    licence_type    = "LINUX" 
    disk_type       = "DAS"
  }
  nic {
    lan             = ionoscloud_lan.example.id
    name            = "Nic Example"
    dhcp            = true
    firewall_active = true
  }
}
resource "random_password" "server_image_password" {
  length           = 16
  special          = false
}
```

### With IPv6 Enabled

```hcl
data "ionoscloud_template" "example" {
  name            = "Basic Cube XS"
}
resource "ionoscloud_datacenter" "example" {
	name            = "Datacenter Example"
	location        = "de/txl"
}
resource "ionoscloud_ipblock" "webserver_ipblock" {
  location = "de/txl"
  size = 4
  name = "webserver_ipblock"
}
resource "ionoscloud_lan" "example" {
  datacenter_id     = ionoscloud_datacenter.example.id
  public            = true
  name              = "Lan Example"
  ipv6_cidr_block = cidrsubnet(ionoscloud_datacenter.example.ipv6_cidr_block,8,10)
}
resource "ionoscloud_cube_server" "example" {
  name              = "Server Example"
  availability_zone = "AUTO"
  image_name        = "ubuntu:latest"
  template_uuid     = data.ionoscloud_template.example.id
  image_password    = random_password.server_image_password.result
  datacenter_id     = ionoscloud_datacenter.example.id
  volume {
    name            = "Volume Example"
    licence_type    = "LINUX" 
    disk_type       = "DAS"
  }
  nic {
    lan             = ionoscloud_lan.example.id
    name            = "Nic Example"
    dhcp            = true
    ips             = [ ionoscloud_ipblock.webserver_ipblock.ips[0], ionoscloud_ipblock.webserver_ipblock.ips[1]]
    
    dhcpv6          = false
    ipv6_cidr_block = cidrsubnet(ionoscloud_lan.example.ipv6_cidr_block,16,5)
    ipv6_ips        = [ 
                        cidrhost(cidrsubnet(ionoscloud_lan.example.ipv6_cidr_block,16,5),1),
                        cidrhost(cidrsubnet(ionoscloud_lan.example.ipv6_cidr_block,16,5),2),
                        cidrhost(cidrsubnet(ionoscloud_lan.example.ipv6_cidr_block,16,5),3)
                      ]

    firewall_active = true
  }
}

resource "random_password" "server_image_password" {
  length           = 16
  special          = false
}
```

## Argument reference

* `template_uuid` - (Required)\[string] The UUID of the template for creating a CUBE server; the available templates for CUBE servers can be found on the templates resource
* `name` - (Required)\[string] The name of the server.
* `datacenter_id` - (Required)\[string] The ID of a Virtual Data Center.
* `hostname` - (Optional)(Computed) The hostname of the resource. Allowed characters are a-z, 0-9 and - (minus). Hostname should not start with minus and should not be longer than 63 characters. If no value provided explicitly, it will be populated with the name of the server
* `image_name` - (Optional)\[string] The name, ID or alias of the image. May also be a snapshot ID. It is required if `licence_type` is not provided. Attribute is immutable.
* `availability_zone` - (Optional)\[string] The availability zone in which the server should exist. This property is immutable.
* `licence_type` - (Optional)\[string] Sets the OS type of the server.
* `vm_state` - (Optional)\[string] Sets the power state of the cube server. E.g: `RUNNING` or `SUSPENDED`.
* `volume` - (Required) See the [Volume](/terraform-provider/resources/volume.md) section.
* `nic` - (Required) See the [Nic](/terraform-provider/resources/nic.md) section.
* `boot_volume` - (Computed) The associated boot volume.
* `boot_cdrom` - ***DEPRECATED*** Please refer to [ionoscloud\_server\_boot\_device\_selection](/terraform-provider/resources/server_boot_device_selection.md) (Optional)\[string] The associated boot drive, if any. Must be the UUID of a bootable CDROM image that can be retrieved using the [ionoscloud\_image](/terraform-provider/data-sources/image.md) data source.
* `boot_image` - (Optional)\[string] The image or snapshot UUID / name. May also be an image alias. It is required if `licence_type` is not provided.
* `primary_nic` - (Computed) The associated NIC.
* `primary_ip` - (Computed) The associated IP address.
* `firewallrule_id` - (Computed) The associated firewall rule.
* `ssh_key_path` - (Optional)\[list] List of paths to files containing a public SSH key that will be injected into IONOS CLOUD provided Linux images. Required for IONOS CLOUD Linux images. Required if `image_password` is not provided.
* `image_password` - (Optional)\[string] Required if `ssh_key_path` is not provided.
* `security_groups_ids` - (Optional) The list of Security Group IDs for the resource.
* `allow_replace` - (Optional)\[bool] When set to true, allows the update of immutable fields by first destroying and then re-creating the server.

⚠️ ***Warning:****&#x20;****`allow_replace`****&#x20;****- lets you update immutable fields, but it first destroys and then re-creates the server in order to do it. This field should be used with care, understanding the risks.***

> **⚠ WARNING**
>
> Image\_name under volume level is deprecated, please use image\_name under server level

> **⚠ WARNING**
>
> For creating a **CUBE** server, you can not set `volume.size` argument.

## Import

Resource Server can be imported using the `resource id` and the `datacenter id`, e.g.

```shell
terraform import ionoscloud_cube_server.myserver datacenter uuid/server uuid
```

## Notes

Please note that for any secondary volume, you need to set the **licence\_type** property to **UNKNOWN**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/terraform-provider/resources/cube_server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
