> ## Documentation Index
> Fetch the complete documentation index at: https://help.onetsolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage your infrastructure with Terraform

> Describe your instances, networks, DNS, domains and web hostings as code with the OnetSolutions provider for Terraform and OpenTofu

The OnetSolutions provider lets you describe your infrastructure in configuration files and create, change or remove it with `terraform apply`. The same configuration works with [Terraform](https://developer.hashicorp.com/terraform/install) and [OpenTofu](https://opentofu.org/docs/intro/install/): both install the provider from their own registry.

> [!NOTE]
>
> **Prerequisites**
>
> * An OnetSolutions account
> * An [API key](https://help.onetsolutions.net/console/api-keys.md)
> * Terraform 1.5 or later, or OpenTofu 1.6 or later

## Get started

**1. Create an API key**

Create an [API key](https://help.onetsolutions.net/console/api-keys.md) in the console. It acts with your rights, in every organization and project you can reach.

**2. Export it**

Keep the key out of your configuration files by passing it in an environment variable:

```bash theme={null}
export ONETSOLUTIONS_API_KEY="sk-onetsolutions-…"
```

**3. Declare the provider**

```hcl theme={null}
terraform {
  required_providers {
    onetsolutions = {
      source  = "onetsolutions-net/onetsolutions"
      version = "~> 0.2"
    }
  }
}

provider "onetsolutions" {}

resource "onetsolutions_ssh_key" "laptop" {
  name       = "laptop"
  public_key = file("~/.ssh/id_ed25519.pub")
}

resource "onetsolutions_vpc" "private" {
  name       = "private"
  cidr_block = "10.0.0.0/16"
}
```

**4. Apply**

```bash theme={null}
terraform init && terraform apply     # or: tofu init && tofu apply
```

When your account has several organizations or projects, set `organization_id` and `project_id` on the provider, or on each resource.

## What you can manage

| Area | What you describe |
| - | - |
| Compute | Instances (with a public IPv6 address if you want one), snapshots, backups, GPUs |
| Network | VPCs, instance firewalls, reverse DNS of your IP addresses |
| Access | SSH keys |
| DNS and domains | Domain registration and settings, DNS zones and records, DNSSEC |
| Web hosting | Web hostings, PHP version, WordPress, databases and their users, mailboxes, FTP accounts, cron jobs, subdomains, addon domains, redirects |

Actions also restart an instance, reinstall it from an image or restore one of its backups, straight from your configuration. Every resource has its page, with examples, in the [provider documentation](https://registry.terraform.io/providers/onetsolutions-net/onetsolutions/latest/docs).

> [!NOTE]
>
> Creating an instance, a web hosting or a domain places an order, billed like an order from the console. The plan tells you before anything is ordered or cancelled.

## Bring existing resources under management

Everything you created in the console can be imported, with an `import` block or `terraform import`. Each resource page gives its import ID:

```hcl theme={null}
import {
  to = onetsolutions_ssh_key.laptop
  id = "<organization_id>/<project_id>/<ssh_key_id>"
}
```

## Get help

For your account, billing or the API, open a ticket from the [console](https://help.onetsolutions.net/console/support.md). To report a bug or suggest a feature for the provider, [open an issue](https://github.com/onetsolutions-net/terraform-provider-onetsolutions/issues/new/choose) on its repository.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.