Skip to main content

Terraform provider

The ariaservice/arianet Terraform provider manages Arianet Cloud resources as code: servers, volumes, private networks (subnets, routes), firewalls, floating IPs, load balancers (services, targets) and your account's SSH keys. It needs Terraform 1.0 or newer.

The provider calls the Cloud API; the full schema of every resource is on the registry.

Provider setup​

terraform {
required_providers {
arianet = {
source = "ariaservice/arianet"
version = "~> 0.1"
}
}
}

provider "arianet" {
# Read from ARIANET_TOKEN when not set here.
token = var.arianet_token
}

variable "arianet_token" {
type = string
sensitive = true
}

Then run terraform init.

Authentication​

Create a personal API token at cloud.ariaservice.net/users/api-tokens with the scopes cloud:servers:read and cloud:servers:write (add the SSH key scopes ssh-keys:read / ssh-keys:write if you manage arianet_ssh_key). Keep it out of your code: export it instead of writing it in a .tf file.

export ARIANET_TOKEN="paste-your-token-here"
terraform plan

Provider arguments​

ArgumentEnvironment variableDefaultMeaning
tokenARIANET_TOKENrequiredAPI token (sensitive)
endpointARIANET_API_URLhttps://api.ariaservice.netAPI root URL. Must be https (plain http only for localhost)
poll_interval2sWait between polls of a running action; grows up to 10s
max_retries5Retries on HTTP 429 (honouring Retry-After, else RateLimit-Reset) and, for reads, on 502/503/504

Long operations return an action; the provider waits for it, bounded by each resource's timeouts block (for example timeouts { create = "20m" }). A resource that answers 404 on refresh is removed from the state.

Resources​

ResourceManages
arianet_serverA cloud server. Changing plan_id resizes it in place; backups turns daily backups on or off; keep_backups / delete_snapshots decide what happens to its copies on destroy.
arianet_volumeA block storage volume (size in GB; growing resizes in place).
arianet_volume_attachmentAttaches a volume to a server.
arianet_networkA private network (ip_range, optional first subnet_ip_range).
arianet_network_subnetAn extra subnet of a network.
arianet_network_routeA static route (destination → gateway) of a network.
arianet_firewallA firewall with its rule blocks and optional apply_to (servers or label selectors).
arianet_firewall_attachmentApplies a firewall to servers (server_ids) or label selectors (label_selectors).
arianet_floating_ipA floating IPv4 or IPv6 address, optional server_id and reverse DNS (dns_ptr).
arianet_floating_ip_assignmentAssigns a floating IP to a server.
arianet_load_balancerA load balancer (type such as lb11, algorithm, optional network_id, public_interface).
arianet_load_balancer_serviceA listener: protocol (tcp, http, https passthrough), ports, health_check, http options.
arianet_load_balancer_targetA target: a server, an IP or a label selector, optionally over the private network.
arianet_ssh_keyAn SSH key of your account.

Every resource supports terraform import, for example terraform import arianet_server.web 123 (sub-resources use compound IDs such as 21/80 for a load balancer service).

Resources that have them accept labels (a map), project_id (defaults to the account's default project; changing it moves the resource) and protection_delete (must be false before the resource can be destroyed).

arianet_server arguments​

ArgumentNotes
name, datacenter, plan_id, imageRequired. datacenter is a location code (arianet_locations), image a slug such as ubuntu-24.04 or a snapshot/backup reference (arianet_image(s)). Changing datacenter or image replaces the server.
ssh_key_ids, ssh_keysSaved key IDs and/or public keys installed at creation
user_datacloud-init user data
enable_ipv4, enable_ipv6Public addresses (IPv4 is on by default)
firewall_ids, network_idsFirewalls applied directly; private networks attached at creation
backupsDaily backups (billed extra)
keep_backupsOn destroy, keep the finished backups (billed per GB afterwards). Sent as ?keep_backups=true.
delete_snapshotsOn destroy, also delete the server's snapshots, which otherwise stay billed. Sent as ?delete_snapshots=true.
start_after_create, protection_delete, protection_rebuild, labels, project_id

Read-only: ipv4_address, ipv6_address, status, disk_gb, locked, rescue_enabled, and root_password (sensitive, returned once at creation; empty when SSH keys are used and the API returns none). Set keep_backups / delete_snapshots and apply before terraform destroy; they are read from the state when the server is deleted.

Data sources​

Data sourceReturns
arianet_locationsDatacenters: code, name, country, features, orderable
arianet_plansPlans (optionally per datacenter): id, name, vcpu, ram_mb, disk_gb, traffic_gb, hourly_price, monthly_price, available
arianet_images, arianet_imageImages by type (system, app, snapshot, backup), datacenter, label_selector; arianet_image picks one by id, image, name or most_recent
arianet_pricingThe public price list (/cloud/v1/public/pricing): server_types with per-location prices, other resources, vat_included
arianet_server_costsGET /servers/{id}/costs: cost lines, totals, snapshots, kept_backups
arianet_load_balancer_typesLoad balancer types and their limits
arianet_server, arianet_networkLook up an existing resource by id, name or label_selector
arianet_ssh_keyLook up one of your SSH keys by id, name or fingerprint

Complete example​

A private network, three web servers behind a load balancer, a firewall that follows the role=web label, and a data volume:

terraform {
required_providers {
arianet = {
source = "ariaservice/arianet"
version = "~> 0.1"
}
}
}

provider "arianet" {} # token from ARIANET_TOKEN

locals {
datacenter = "ovh"
}

data "arianet_plans" "dc" {
datacenter = local.datacenter
}

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

resource "arianet_network" "private" {
name = "private"
datacenter = local.datacenter
ip_range = "10.0.0.0/16"
subnet_ip_range = "10.0.1.0/24"
}

resource "arianet_server" "web" {
count = 3
name = "web-${count.index + 1}"
datacenter = local.datacenter
plan_id = data.arianet_plans.dc.plans[0].id
image = "ubuntu-24.04"
ssh_key_ids = [arianet_ssh_key.me.id]
network_ids = [arianet_network.private.id]
labels = { role = "web" }

user_data = <<-EOT
#cloud-config
packages: [nginx]
EOT
}

resource "arianet_firewall" "web" {
name = "web"

rule {
direction = "in"
protocol = "tcp"
port = "22"
source_ips = ["203.0.113.4/32"]
}

rule {
direction = "in"
protocol = "tcp"
port = "80"
source_ips = ["0.0.0.0/0", "::/0"]
}

apply_to = [{ label_selector = "role=web" }]
}

resource "arianet_load_balancer" "web" {
name = "web"
datacenter = local.datacenter
type = "lb11"
algorithm = "round_robin"
network_id = arianet_network.private.id
}

resource "arianet_load_balancer_service" "http" {
load_balancer_id = arianet_load_balancer.web.id
protocol = "http"
listen_port = 80
destination_port = 80

health_check = {
protocol = "http"
port = 80
interval = 10
timeout = 5
retries = 3
http = {
path = "/"
status_codes = ["2??"]
}
}
}

resource "arianet_load_balancer_target" "web" {
load_balancer_id = arianet_load_balancer.web.id
type = "label_selector"
label_selector = "role=web"
use_private_ip = true
}

resource "arianet_volume" "data" {
name = "data"
datacenter = local.datacenter
size = 50
filesystem = "ext4"
}

resource "arianet_volume_attachment" "data" {
volume_id = arianet_volume.data.id
server_id = arianet_server.web[0].id
}

data "arianet_server_costs" "web1" {
server_id = arianet_server.web[0].id
}

output "load_balancer_ip" {
value = arianet_load_balancer.web.ipv4
}

output "web1_monthly_cost" {
value = data.arianet_server_costs.web1.totals
}
export ARIANET_TOKEN="..."
terraform init
terraform plan
terraform apply

Prices before you apply: curl -s https://api.ariaservice.net/cloud/v1/public/pricing or arianet cloud pricing (no token needed).

See also​