A Terraform/OpenTofu provider for managing Vast.ai GPU compute infrastructure.
terraform {
required_providers {
vastai = {
source = "realnedsanders/vastai"
version = "~> 0.1"
}
}
}
provider "vastai" {
# API key can be set via VASTAI_API_KEY environment variable (recommended)
# api_key = "your-api-key-here"
}The provider requires a Vast.ai API key. Set it via environment variable:
export VASTAI_API_KEY="your-api-key"
terraform planOr configure it directly in the provider block (not recommended for version control):
provider "vastai" {
api_key = "your-api-key-here"
}| Resource | Description |
|---|---|
vastai_instance |
GPU compute instance with full lifecycle management |
vastai_template |
Reusable container configuration template |
vastai_ssh_key |
SSH public key for instance access |
vastai_volume |
Persistent local storage volume |
vastai_network_volume |
Network-attached storage volume |
vastai_endpoint |
Serverless inference endpoint with autoscaling |
vastai_worker_group |
Worker group bound to a serverless endpoint |
vastai_api_key |
API key with permission scoping |
vastai_environment_variable |
Account-level environment variable |
vastai_team |
Team for multi-user collaboration |
vastai_team_role |
Role with granular permissions for a team |
vastai_team_member |
Team member (invite on create, remove on destroy) |
vastai_subaccount |
Sub-account for organizational hierarchy |
vastai_cluster |
Physical GPU cluster |
vastai_cluster_member |
Machine membership in a cluster |
vastai_overlay |
Overlay network on top of a cluster |
vastai_overlay_member |
Instance membership in an overlay network |
| Data Source | Description |
|---|---|
vastai_gpu_offers |
Search GPU marketplace offers with filters |
vastai_instance |
Look up a single instance by ID |
vastai_instances |
List instances with optional filtering |
vastai_templates |
Search templates by query |
vastai_ssh_keys |
List all SSH keys |
vastai_volume_offers |
Search volume offers with filters |
vastai_network_volume_offers |
Search network volume offers |
vastai_endpoints |
List serverless endpoints |
vastai_user |
Current account profile |
vastai_invoices |
Billing invoice history |
vastai_audit_logs |
Account activity audit trail |
git clone https://github.com/realnedsanders/terraform-provider-vastai.git
cd terraform-provider-vastai
make build- Go 1.25+
- GNU Make
make build # Build the provider binary
make lint # Run golangci-lint
make test # Run unit tests
make testacc # Run acceptance tests (requires VASTAI_API_KEY)Unit tests:
make testAcceptance tests require a Vast.ai account and API key:
export VASTAI_API_KEY="your-api-key"
make testaccTo install the provider locally for testing:
make installFull documentation is available on the Terraform Registry.
This project is licensed under the MPL-2.0 License — see the LICENSE file for details.