> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/tools-terraform/docs/resources/datacenter.md).

# ionoscloud\_datacenter

Creates and manages IONOS CLOUD Virtual Data Center.

Manages a Virtual [Data Center](https://docs.ionos.com/cloud/set-up-ionos-cloud/get-started/configure-data-center) on IONOS CLOUD.

## Example Usage

```hcl
resource "ionoscloud_datacenter" "example" {
  name                = "Datacenter Example"
  location            = "us/las"
  description         = "datacenter description"
  sec_auth_protection = false
}
```

## Attaching a NSG to a Datacenter

A single Network Security Group can be attached at any time to a Datacenter. To do this, use the `ionoscloud_datacenter_nsg_selection` and provide the IDs of the NSG and Datacenter to link them. Deleting the resource or setting the empty string for the `nsg_id` field will de-attach any previously linked NSG from the Datacenter.

```hcl
resource "ionoscloud_datacenter" "example" {
  name            = "Datacenter NSG Example"
  location        = "de/txl"
}
resource "ionoscloud_nsg" "example" {
  name              = "Example NSG"
  description       = "Example NSG Description"
  datacenter_id     = ionoscloud_datacenter.example.id
}
resource "ionoscloud_datacenter_nsg_selection" "example"{
  datacenter_id     = ionoscloud_datacenter.example.id
  nsg_id            = ionoscloud_nsg.example.id
}
```

## Argument Reference

The following arguments are supported:

* `name` - (Required)\[string] The name of the Virtual Data Center.
* `location` - (Required)\[string] The regional location where the Virtual Data Center will be created. This argument is immutable. Available locations: `de/fra`, `us/las`, `us/ewr`, `de/txl`, `gb/lhr`, `gb/bhx`, `es/vit`, `fr/par`, `us/mci`, `de/fra/1`, `de/fra/2`
* `description` - (Optional)\[string] Description for the Virtual Data Center.
* `sec_auth_protection` - (Optional) \[bool] Boolean value representing if the data center requires extra protection e.g. two factor protection
* `version` - (Computed) The version of that Data Center. Gets incremented with every change
* `features` - (Computed) List of features supported by the location this data center is part of
* `ipv6_cidr_block` - (Computed) The automatically-assigned /56 IPv6 CIDR block if IPv6 is enabled on this virtual data center
* `cpu_architecture` - (Computed) Array of features and CPU families available in a location
  * `cpu_family` - A valid CPU family name
  * `max_cores` - The maximum number of cores available
  * `max_ram` - The maximum number of RAM in MB
  * `vendor` - A valid CPU vendor name
  * `enabled_features` - Features enabled for this CPU architecture, e.g. `SEV-SNP` for Confidential Computing

## Import

Resource Datacenter can be imported using the `resource id`, e.g.

```shell
import {
  to = ionoscloud_datacenter.example
  id = "datacenter uuid" 
}
```

Auto-generate the datacenter resource in the `dc.tf` file using the following command:

```shell
terraform plan -generate-config-out=dc.tf
```

The older syntax can be for importing the resource is still supported:

```shell
terraform import ionoscloud_datacenter.mydc datacenter uuid
```

In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can also be used with the `identity` attribute:

```hcl
import {
  to = ionoscloud_datacenter.example
  identity = {
    id = "datacenter uuid"
  }
}

resource "ionoscloud_datacenter" "example" {
  ### Configuration omitted for brevity ###
}
```

### Identity Schema

#### Required

* `id` (String) The UUID of the datacenter.

#### Optional

* `location` (String) The location the datacenter lives in (e.g. `de/txl`). Only needed when the Cloud API endpoint is overridden per location.

## Query (List Resource)

Datacenters can be listed using `terraform query` (requires Terraform 1.14+). List blocks must be placed in a dedicated query file, whose name ends in `.tfquery.hcl` (for example `queries.tfquery.hcl`).

```hcl
list "ionoscloud_datacenter" "all" {
  provider         = ionoscloud
  include_resource = true
}
```

See the [`ionoscloud_datacenter` list resource documentation](https://docs.ionos.com/cloud/tools-terraform/docs/list-resources/datacenter.md) for filters and the full attribute reference.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ionos.com/cloud/tools-terraform/docs/resources/datacenter.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
