Terraform provider
- Installation
- Provider Configuration
- Resource: virtuoso_vm
- Resource: virtuoso_k8s_cluster
- Resource: virtuoso_docker_instance
- Resource: virtuoso_aws_instance
- Resource: virtuoso_vm_schedule
- Resource: virtuoso_restore_policy
- Resource: virtuoso_snapshot
- Resource: virtuoso_ssh_key
- Resource: virtuoso_vm_access
- Data Source: virtuoso_vm
- Data Source: virtuoso_vms
- Full Example
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
}
| Attribute | Type | Description |
|---|---|---|
endpoint | String | Server URL. Env: VIRTUOSO_ENDPOINT |
api_key sensitive | String | API key (vmk_...). Env: VIRTUOSO_API_KEY |
insecure | Bool | Skip TLS verification. Env: VIRTUOSO_INSECURE |
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
| Attribute | Type | Description |
|---|---|---|
name required force new | String | VM name (1-63 chars, alphanumeric/hyphens/underscores/dots) |
os optional force new | String | OS image: ubuntu-26.04, ubuntu-24.04 (default), ubuntu-22.04, fedora-43, amazon-2023. Ignored when iso is set |
iso optional force new | String | Absolute 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 new | String | micro (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 new | String | SSH public key to inject |
disk_gb optional | Int | Disk size in GB. Can be increased in-place; cannot be shrunk |
password optional sensitive force new | String | VM password. Auto-generated if omitted |
vnc optional force new | Bool | Enable VNC graphics |
desktop optional force new | Bool | Install desktop environment (implies VNC) |
user_script optional force new | String | Shell commands to run on first boot via cloud-init |
post_tailscale_script optional force new | String | Bash 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 optional | Bool | Use 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 optional | Bool | Start VM automatically on host boot. Default: false. Updateable in-place |
protected optional | Bool | Delete protection. When enabled, the VM cannot be deleted until protection is disabled. Default: false. Updateable in-place. Terraform auto-unprotects before destroy |
notes optional | String | Free 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 optional | Bool | Whether the VM should be running. Default: true. Updateable in-place |
Read-Only Attributes
| Attribute | Type | Description |
|---|---|---|
ip | String | VM IP address |
state | String | VM state: running, shutoff, creating |
vcpus | Int | Number of virtual CPUs |
memory_mb | Int | Memory in MB |
disk_cap_gb | Float | Disk capacity in GB |
disk_used_gb | Float | Disk used in GB |
has_vnc | Bool | Whether VNC is available |
cloud_init | String | Cloud-init status (running, done, error) |
network | String | Network identifier: "default" for NAT or "bridge:br0" for bridged |
os_id | String | OS identifier from server |
password sensitive | String | VM password (captured at creation) |
Update Behavior
autostart: toggles autostart on/offstarted: starts or gracefully stops the VMdisk_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 beforeterraform destroy)notes: replaces the VM's notes
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
}
| Attribute | Type | Description |
|---|---|---|
name required force new | String | Cluster name. The VM is named k8s-<name> |
size optional force new | String | Server node size. Default medium |
disk_gb optional force new | Number | Disk size in GB. 0 uses the size's default |
bridged optional force new | Bool | Bridged networking instead of NAT. Default false |
worker_count optional | Number | Workers, 0 to 10. Changed in place: scaling down drains and removes the newest workers |
argocd, headlamp, k9s optional | Bool | Install the add-on. Can be turned on later in place; removing one requires recreating the cluster |
id, vm_name, status, ip, tailscale_ip computed | String | Cluster identity and server node address |
kubeconfig, argocd_password, headlamp_token sensitive | String | Admin 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"
}
| Attribute | Type | Description |
|---|---|---|
name required force new | String | Instance name. The VM is named docker-<name> |
size optional force new | String | Default medium |
disk_gb optional force new | Number | Disk size in GB. 0 uses the size's default |
bridged optional force new | Bool | Bridged networking instead of NAT. Default false |
id, vm_name, status, ip, tailscale_ip computed | String | Instance 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 }
| Attribute | Type | Description |
|---|---|---|
name required force new | String | Instance name. It must not already be in use |
instance_type optional force new | String | t3.micro (default), t3.small, t3.medium, t3.large, t3.xlarge, t3.2xlarge, m5.2xlarge or m5.4xlarge |
region optional force new | String | A region the account can use. Defaults to the default region in the server's Settings |
os optional force new | String | ubuntu-24.04 (default), ubuntu-26.04, ubuntu-22.04 or amazon-2023 |
ssh_key, user_script optional force new | String | An SSH public key to install, and a shell script to run on first boot |
disk_gb optional force new | Number | Root 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 new | List of objects | Extra 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 computed | String, number | The 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 sensitive | String | A 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"
}
| Attribute | Type | Description |
|---|---|---|
vm required force new | String | Name of the VM |
days optional | String | everyday (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 optional | String | HH:MM on a 24 hour clock. Set at least one. They cannot be equal |
tz optional | String | IANA time zone. Empty uses the server's zone |
enabled optional | Bool | Default true. false keeps the times but turns the schedule off |
id, last_action, last_at, last_error computed | String | The 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"
}
| Attribute | Type | Description |
|---|---|---|
vm required force new | String | Name of the VM |
at required | String | Time of day, HH:MM on a 24 hour clock |
retention_days required | Number | 1, 3, 5, 7, 14 or 28. Checked at plan time |
days optional | String | Same values as virtuoso_vm_schedule. Default everyday |
tz, enabled optional | String, Bool | Time zone (empty is the server's) and an on/off switch, default true |
estimated_copies, estimated_bytes, last_at, last_result, last_error, id computed | Number, String | How 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.
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"
}
| Attribute | Type | Description |
|---|---|---|
vm required force new | String | Name of the VM |
name optional force new | String | A label, up to 80 characters |
retention_days optional force new | Number | Default 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 computed | String, Number | id 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
| Attribute | Type | Description |
|---|---|---|
name required force new | String | Display name for the key |
public_key required force new | String | SSH public key content (ssh-rsa, ssh-ed25519, or ecdsa-sha2-*) |
Read-Only Attributes
| Attribute | Type | Description |
|---|---|---|
id | String | Server-assigned key ID |
created_at | String | Creation 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
| Attribute | Type | Description |
|---|---|---|
vm_name required force new | String | Name of the VM |
user_id required force new | Int | ID of the user to grant access |
Read-Only Attributes
| Attribute | Type | Description |
|---|---|---|
id | String | Synthetic 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