Docs/Reference
Reference

Terraform provider for GPUwerk

By Samuel Seidel · Updated November 24, 2026 · 6 min read

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).

On this page
  1. Create an API key
  2. Deploy a Spark
  3. Connect
  4. Choose image, location and a time limit
  5. Terminate it
  6. Import an instance you already have
  7. What the provider manages

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:

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

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.

NextAPI reference Back toAll docs
Top up from $5, billed per minute

Deploy your first Spark from Terraform.

A dedicated DGX Spark in Europe, North America or East Asia, through the console.

Create account