virtuOSo docs v0.8.1

Terraform provider

Installation

The provider is published on the Terraform registry. Declare it and run terraform init; nothing else is needed:

terraform {
  required_providers {
    virtuoso = {
      source  = "rickjacobo/virtuoso"
      version = "~> 0.4"
    }
  }
}

For a machine that cannot reach the registry, download the provider for your platform from the releases page and unzip it. A virtuOSo server also offers a one line installer and cached copies on its own Terraform documentation page.

If you downloaded the binary yourself, place it at the path below. The same required_providers block then finds it:

~/.terraform.d/plugins/registry.terraform.io/rickjacobo/virtuoso/0.5.0/OS_ARCH/terraform-provider-virtuoso

Provider Configuration

Configure the provider with your virtuOSo server endpoint and an API key. Create an API key from the Profile page.

provider "virtuoso" {
  endpoint = "https://your-server"
  api_key  = var.virtuoso_api_key
  insecure = true  # for self-signed TLS certs
}
AttributeTypeDescription
endpointStringServer URL. Env: VIRTUOSO_ENDPOINT
api_key sensitiveStringAPI key (vmk_...). Env: VIRTUOSO_API_KEY
insecureBoolSkip TLS verification. Env: VIRTUOSO_INSECURE
All attributes can be set via environment variables as an alternative to hardcoding in config files.

Resource: virtuoso_vm

Manages a virtual machine. Most fields are immutable. Changing them destroys and recreates the VM.

resource "virtuoso_vm" "web" {
  name      = "web-server"
  size      = "medium"
  os        = "ubuntu-24.04"
  disk_gb   = 40
  ssh_key   = virtuoso_ssh_key.deploy.public_key
  started   = true
  autostart = true
}

Arguments

AttributeTypeDescription
name required force newStringVM name (1-63 chars, alphanumeric/hyphens/underscores/dots)
os optional force newStringOS image: ubuntu-26.04, ubuntu-24.04 (default), ubuntu-22.04, fedora-43, amazon-2023. Ignored when iso is set
iso optional force newStringAbsolute path to an ISO file on the server. When set, the VM boots from the ISO instead of a cloud image (os is ignored, VNC is auto-enabled). Upload ISOs via Settings > Storage; they are stored at /var/lib/vm-lab/vms/isos/
size optional force newStringmicro (1 vCPU/1 GB), small (1/2 GB), medium (2/4 GB), large (2/8 GB), xlarge (4/16 GB), 2xlarge (8/24 GB), 3xlarge (8/32 GB), 4xlarge (16/64 GB). Default: small
ssh_key optional force newStringSSH public key to inject
disk_gb optionalIntDisk size in GB. Can be increased in-place; cannot be shrunk
password optional sensitive force newStringVM password. Auto-generated if omitted
vnc optional force newBoolEnable VNC graphics
desktop optional force newBoolInstall desktop environment (implies VNC)
user_script optional force newStringShell commands to run on first boot via cloud-init
post_tailscale_script optional force newStringBash script that runs once after Tailscale connects. It sees TS_IP and TS_DNSNAME (empty if Tailscale is not configured), survives a reboot during first boot, and is retried at the next boot if it fails. See the Tailscale guide. Requires a server that supports it.
bridged optionalBoolUse bridged networking (VM gets a LAN IP from router DHCP) instead of NAT. Default: false. Updateable in-place (stops VM, switches network, restarts automatically)
autostart optionalBoolStart VM automatically on host boot. Default: false. Updateable in-place
protected optionalBoolDelete protection. When enabled, the VM cannot be deleted until protection is disabled. Default: false. Updateable in-place. Terraform auto-unprotects before destroy
notes optionalStringFree text (Markdown) notes for the VM, up to 64 KB. Updateable in-place. If you leave it out, Terraform keeps whatever notes are on the VM and does not clear notes written in the web UI. Set it to "" to clear them
started optionalBoolWhether the VM should be running. Default: true. Updateable in-place

Read-Only Attributes

AttributeTypeDescription
ipStringVM IP address
stateStringVM state: running, shutoff, creating
vcpusIntNumber of virtual CPUs
memory_mbIntMemory in MB
disk_cap_gbFloatDisk capacity in GB
disk_used_gbFloatDisk used in GB
has_vncBoolWhether VNC is available
cloud_initStringCloud-init status (running, done, error)
networkStringNetwork identifier: "default" for NAT or "bridge:br0" for bridged
os_idStringOS identifier from server
password sensitiveStringVM password (captured at creation)

Update Behavior

In-place updates (no VM replacement):
  • autostart: toggles autostart on/off
  • started: starts or gracefully stops the VM
  • disk_gb: grows the disk (stops VM, resizes, restarts automatically)
  • bridged: switches between NAT and bridged networking (stops VM, switches, restarts automatically)
  • protected: enables or disables delete protection (Terraform auto-unprotects before terraform destroy)
  • notes: replaces the VM's notes
Disk resize requires a VM restart. The provider handles the stop → resize → start sequence automatically. Disks can only be grown, not shrunk.

Import

terraform import virtuoso_vm.web web-server

Import by VM name. Config-only fields (size, os, etc.) will be empty after import. Fill them in or use ignore_changes.

Resource: virtuoso_k8s_cluster

Manages a k3s Kubernetes cluster (the Kubernetes app). Requires an admin API key. Create waits until the server is running and the worker VMs are up, and returns the kubeconfig. Workers join the cluster about a minute after their VM is up, so use kubectl to confirm nodes are Ready before scheduling work.

resource "virtuoso_k8s_cluster" "dev" {
  name         = "dev"
  size         = "large"
  worker_count = 2
  argocd       = true
}

output "kubeconfig" {
  value     = virtuoso_k8s_cluster.dev.kubeconfig
  sensitive = true
}
AttributeTypeDescription
name required force newStringCluster name. The VM is named k8s-<name>
size optional force newStringServer node size. Default medium
disk_gb optional force newNumberDisk size in GB. 0 uses the size's default
bridged optional force newBoolBridged networking instead of NAT. Default false
worker_count optionalNumberWorkers, 0 to 10. Changed in place: scaling down drains and removes the newest workers
argocd, headlamp, k9s optionalBoolInstall the add-on. Can be turned on later in place; removing one requires recreating the cluster
id, vm_name, status, ip, tailscale_ip computedStringCluster identity and server node address
kubeconfig, argocd_password, headlamp_token sensitiveStringAdmin kubeconfig and add-on credentials. They are stored in the Terraform state, so protect the state file. The add-on values fill in once the add-on has finished installing

Import an existing cluster with terraform import virtuoso_k8s_cluster.dev dev.

Resource: virtuoso_docker_instance

Manages a Docker instance (the Docker app): a VM with Docker and Compose installed. Requires an admin API key. Every argument is fixed at creation; changing one recreates the instance. Look up the VM's login details with the virtuoso_vm data source using vm_name.

resource "virtuoso_docker_instance" "tools" {
  name = "tools"
  size = "medium"
}
AttributeTypeDescription
name required force newStringInstance name. The VM is named docker-<name>
size optional force newStringDefault medium
disk_gb optional force newNumberDisk size in GB. 0 uses the size's default
bridged optional force newBoolBridged networking instead of NAT. Default false
id, vm_name, status, ip, tailscale_ip computedStringInstance identity and address

Resource: virtuoso_aws_instance

Launches an EC2 instance through virtuOSo, in the AWS account saved under Settings > AWS on the server. The AWS credentials stay on the virtuOSo server and never reach Terraform. Requires an admin API key, virtuOSo v0.8.0 or later, and provider v0.5.0 or later.

It costs money while it runs, and running terraform apply is the confirmation. Each instance type's price is shown in the Launch on AWS form. terraform destroy terminates the instance and removes the security groups made for it. There is no automatic termination in Terraform, because an instance that ended by itself would no longer match its state; use the Launch on AWS form or vm fleet aws-launch for a self-terminating instance. Only instances launched through virtuOSo this way can be destroyed this way. Every argument is fixed at creation, so changing one replaces the instance.

resource "virtuoso_aws_instance" "web" {
  name          = "web-01"
  instance_type = "t3.micro"
  os            = "ubuntu-24.04"
  ssh_key       = file("~/.ssh/id_ed25519.pub")
  disk_gb       = 40

  ports = [
    { port = 443 },
    { port = 8080, source = "203.0.113.7/32" },
  ]
}

output "address" { value = virtuoso_aws_instance.web.ip }
AttributeTypeDescription
name required force newStringInstance name. It must not already be in use
instance_type optional force newStringt3.micro (default), t3.small, t3.medium, t3.large, t3.xlarge, t3.2xlarge, m5.2xlarge or m5.4xlarge
region optional force newStringA region the account can use. Defaults to the default region in the server's Settings
os optional force newStringubuntu-24.04 (default), ubuntu-26.04, ubuntu-22.04 or amazon-2023
ssh_key, user_script optional force newStringAn SSH public key to install, and a shell script to run on first boot
disk_gb optional force newNumberRoot disk size in GB, 8 to 2000. Left out, the image's own size (8 GB) is used. The disk is billed while the instance exists, about $0.08 per GB a month, and is deleted with it
ports optional force newList of objectsExtra ports to open, each with port and an optional source CIDR that defaults to 0.0.0.0/0. SSH is always open. At most 10
id, state, public_ip, private_ip, ip, vcpus, estimated_hourly_usd computedString, numberThe EC2 instance id, its state, addresses (ip is the public address, or the private one if there is none), vCPUs, and the estimated cost per hour
password sensitiveStringA password virtuOSo generated. It is stored in the Terraform state, so protect the state file

Resource: virtuoso_vm_schedule

Starts and stops a VM automatically at set times. A VM has no schedule until one is created. Works for on-prem VMs and for AWS instances that virtuOSo launched. Requires virtuOSo v0.7.0 or later, and an API key with access to the VM. See Schedules, Snapshots and Restore Points.

resource "virtuoso_vm_schedule" "dev" {
  vm       = "dev-box"
  days     = "weekdays"
  start_at = "08:00"
  stop_at  = "19:00"
  tz       = "America/New_York"
}
AttributeTypeDescription
vm required force newStringName of the VM
days optionalStringeveryday (default), weekdays, weekends, or lowercase names in week order such as mon,wed,fri. Other spellings are rejected at plan time with the form to use instead
start_at, stop_at optionalStringHH:MM on a 24 hour clock. Set at least one. They cannot be equal
tz optionalStringIANA time zone. Empty uses the server's zone
enabled optionalBoolDefault true. false keeps the times but turns the schedule off
id, last_action, last_at, last_error computedStringThe VM name, and the last action taken with its result

Import with the VM name: terraform import virtuoso_vm_schedule.dev dev-box.

Resource: virtuoso_restore_policy

Takes an automatic snapshot of a VM at a set time on chosen days and deletes each one after retention_days. A VM has no restore point policy until one is created. Each snapshot is a full copy, so long retention uses a lot of disk space on-prem; check estimated_bytes. A run is skipped, with the reason in last_error, if disk space is short or the VM is busy.

resource "virtuoso_restore_policy" "dev" {
  vm             = "dev-box"
  at             = "02:00"
  retention_days = 7
  tz             = "America/New_York"
}
AttributeTypeDescription
vm required force newStringName of the VM
at requiredStringTime of day, HH:MM on a 24 hour clock
retention_days requiredNumber1, 3, 5, 7, 14 or 28. Checked at plan time
days optionalStringSame values as virtuoso_vm_schedule. Default everyday
tz, enabled optionalString, BoolTime zone (empty is the server's) and an on/off switch, default true
estimated_copies, estimated_bytes, last_at, last_result, last_error, id computedNumber, StringHow many snapshots exist at once and roughly how much space they use (zero on AWS, where snapshots use no local space), and the last run: started or skipped

Import with the VM name: terraform import virtuoso_restore_policy.dev dev-box.

Resource: virtuoso_snapshot

Takes a snapshot, a full copy of a VM's disk, and deletes it when the resource is destroyed. Create waits until the snapshot is ready. A snapshot of a running VM is crash consistent, as if the power had been cut. Every argument is fixed at creation, so changing one takes a new snapshot.

Restoring is not a Terraform resource. A restore is an action, not a state to maintain, so a restore resource would repeat or drift on later runs. Restore from the web UI, the API, the CLI or MCP. A snapshot with retention_days above 0 is deleted by virtuOSo when it expires, and Terraform then plans to create it again. Leave retention_days at its default of 0 for snapshots Terraform should keep.
resource "virtuoso_snapshot" "before_upgrade" {
  vm   = "dev-box"
  name = "before upgrade"
}
AttributeTypeDescription
vm required force newStringName of the VM
name optional force newStringA label, up to 80 characters
retention_days optional force newNumberDefault 0, which keeps the snapshot until the resource is destroyed. Otherwise 1, 3, 5, 7, 14 or 28
id, snapshot_id, status, source, size_bytes, consistency, created_at, expires_at computedString, Numberid is vm/snapshot_id. consistency is clean or crash-consistent

Import with vm/snapshot_id: terraform import virtuoso_snapshot.before_upgrade dev-box/snap-20260301-020000-ab12cd.

Resource: virtuoso_ssh_key

Manages an SSH public key associated with your account. Immutable. Any change recreates the key.

resource "virtuoso_ssh_key" "deploy" {
  name       = "deploy-key"
  public_key = file("~/.ssh/id_ed25519.pub")
}

Arguments

AttributeTypeDescription
name required force newStringDisplay name for the key
public_key required force newStringSSH public key content (ssh-rsa, ssh-ed25519, or ecdsa-sha2-*)

Read-Only Attributes

AttributeTypeDescription
idStringServer-assigned key ID
created_atStringCreation timestamp

Import

terraform import virtuoso_ssh_key.deploy 42

Import by numeric key ID.

Resource: virtuoso_vm_access

Grants a user access to a VM. Admin-only. Immutable. Any change recreates the grant.

resource "virtuoso_vm_access" "dev_access" {
  vm_name = virtuoso_vm.web.name
  user_id = 2
}

Arguments

AttributeTypeDescription
vm_name required force newStringName of the VM
user_id required force newIntID of the user to grant access

Read-Only Attributes

AttributeTypeDescription
idStringSynthetic ID: {vm_name}/{user_id}

Import

terraform import virtuoso_vm_access.dev_access web-server/2

Data Source: virtuoso_vm

Reads details of an existing VM.

data "virtuoso_vm" "existing" {
  name = "web-server"
}

output "vm_ip" {
  value = data.virtuoso_vm.existing.ip
}

Returns all read-only VM attributes: state, ip, vcpus, memory_mb, disk_cap_gb, disk_used_gb, has_vnc, cloud_init, network, password, os_id, autostart, notes.

Data Source: virtuoso_vms

Lists all VMs you have access to.

data "virtuoso_vms" "all" {}

output "vm_names" {
  value = [for vm in data.virtuoso_vms.all.vms : vm.name]
}

Returns a vms list, each with: name, state, ip, vcpus, memory_mb, autostart, has_vnc, disk_cap_gb, disk_used_gb, cloud_init, network.

Full Example

terraform {
  required_providers {
    virtuoso = {
      source = "rickjacobo/virtuoso"
    }
  }
}

provider "virtuoso" {
  endpoint = "https://your-server"
  api_key  = var.virtuoso_api_key
  insecure = true
}

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

# Upload your SSH key
resource "virtuoso_ssh_key" "deploy" {
  name       = "deploy-key"
  public_key = file("~/.ssh/id_ed25519.pub")
}

# Launch a VM
resource "virtuoso_vm" "web" {
  name      = "web-server"
  size      = "medium"
  os        = "ubuntu-24.04"
  disk_gb   = 40
  ssh_key   = virtuoso_ssh_key.deploy.public_key
  started   = true
  autostart = true

  user_script = <<-EOT
    apt-get update
    apt-get install -y nginx
  EOT
}

# Launch a VM with bridged networking (LAN IP from router DHCP)
resource "virtuoso_vm" "lan" {
  name    = "lan-server"
  size    = "medium"
  os      = "ubuntu-24.04"
  bridged = true
}

# Boot a VM from an ISO (for manual OS installs)
# Upload ISOs via Settings > Storage, then reference the path below
resource "virtuoso_vm" "custom" {
  name = "custom-os"
  size = "large"
  iso  = "/var/lib/vm-lab/vms/isos/my-installer.iso"
}

# Grant another user access
resource "virtuoso_vm_access" "dev" {
  vm_name = virtuoso_vm.web.name
  user_id = 2
}

output "web_ip" {
  value = virtuoso_vm.web.ip
}

output "web_password" {
  value     = virtuoso_vm.web.password
  sensitive = true
}
# Apply
export VIRTUOSO_API_KEY="vmk_your_key_here"
terraform init
terraform plan
terraform apply