Terraform provider for GPUwerk
Our Terraform provider deploys and terminates GPUwerk instances, such as a dedicated DGX Spark, and manages the SSH keys on your account. It is published on the Terraform Registry as gpuwerkcom/gpuwerk, and the source is on GitHub under the MPL-2.0 licence. It talks to the same public API as the console, described in the API reference.
Instances are billed per minute while they exist. terraform destroy terminates them: billing ends and the workspace is deleted. The provider never stops or starts an instance, because a stopped instance is still billed. Copy anything you want to keep out of /workspace first (see Get your files out).
1. Create an API key
In the console, open API keys and create a key with the read and instances scopes. Add ssh_keys if Terraform should register SSH keys too. Then export it in the shell you run Terraform from:
export GPUWERK_API_KEY=sy_key_...
Keep the key out of your configuration files and state; the provider reads the environment variable by itself.
About the ssh_keys scope. A key that can register an SSH key can give itself root on every instance the account deploys afterwards. Grant it only to the key Terraform uses, and keep that key as safe as the account itself.
2. Deploy a Spark
A complete configuration: the provider, your SSH public key, and one DGX Spark.
terraform {
required_providers {
gpuwerk = {
source = "gpuwerkcom/gpuwerk"
}
}
}
# Reads GPUWERK_API_KEY.
provider "gpuwerk" {}
resource "gpuwerk_ssh_key" "laptop" {
name = "laptop"
public_key = file("~/.ssh/id_ed25519.pub")
}
resource "gpuwerk_instance" "spark" {
name = "train-1"
type = "spark-1x"
ssh_key_id = gpuwerk_ssh_key.laptop.id
}
output "ssh" {
value = "ssh -p ${gpuwerk_instance.spark.ssh_port} ${gpuwerk_instance.spark.ssh_user}@${gpuwerk_instance.spark.ssh_host}"
}
terraform init terraform apply
Result: apply waits until the instance is running (set wait_for_running = false to return straight away) and prints the SSH command. Billing starts with the deploy, at the rate of the instance type; the instance's rate attribute shows it.
No SSH key yet? Create one first. Without ssh_key_id, the newest key on your account is installed, and the browser terminal in the console works without any key.
3. Connect
# runs the printed command
$(terraform output -raw ssh)
Or use the attributes directly in your own tooling: ssh_host, ssh_port, ssh_user, public_ipv4 and public_hostname. Model images also export https_endpoint. A terraform_data resource with remote-exec provisioners can copy your code in and start it once the instance is up.
4. Choose image, location and a time limit
Look up what you can deploy with the data sources, which read public endpoints and need no key:
data "gpuwerk_instance_types" "all" {}
data "gpuwerk_images" "all" {}
data "gpuwerk_locations" "all" {}
The settings you will use most on gpuwerk_instance:
type:spark-1xfor one dedicated Spark, orspark-2xtospark-8xfor a Spark Cluster of that many cabled machines, deployed as one instance.image: an image id, for exampledgx-os(the default),ubuntu, or a model image such asqwen3-coder-30b. Spark images are ARM64, so build and pull arm64 containers.region:eeafor any machine in the EU/EEA, a region id fromgpuwerk_locationssuch aseurope, or a country code such asDE. Left out, any location, which can be outside the EU/EEA.only_internal:trueto take only a Spark GPUwerk owns, in our datacenter in Hradec Králové.max_lifetime_minutes: a safety net. The API terminates the instance this many minutes after the deploy, whatever Terraform does, and deletes the workspace. Useful for CI and experiments you might forget.
Changing type, image, region or most other inputs replaces the instance: Terraform terminates it and deploys a new one, and the old workspace is gone. terraform plan marks this as must be replaced; read the plan before you apply.
5. Terminate it
terraform destroy
Result: the instance is terminated, billing ends, and its workspace is deleted. We keep no copy of a workspace. An instance you terminate in the console disappears from Terraform's state on the next plan, and the next apply deploys a new one.
6. Import an instance you already have
An instance deployed in the console can be brought under Terraform by its id:
terraform import gpuwerk_instance.spark i-0123456789
The API does not return ssh_key_id, region or only_internal, so those are empty after an import; setting them in configuration afterwards records them without replacing the instance.
What the provider manages
- Resources:
gpuwerk_instance(deploy, read, import, terminate) andgpuwerk_ssh_key(needs thessh_keysscope). - Data sources:
gpuwerk_instance,gpuwerk_instance_types,gpuwerk_images,gpuwerk_locationsandgpuwerk_ssh_keys.
Every attribute is documented on the Registry. For a CI-style walkthrough with a time limit and a Spark Cluster, read Deploy a DGX Spark with Terraform on our blog. Found a bug or missing a field? Open an issue on GitHub or write to us.