A Terraform provider for managing RunPod infrastructure using the Terraform Plugin Framework.
- Go 1.21 or higher (for development)
- Terraform 1.0 or higher
- RunPod API token
This provider uses Terraform's dev_overrides feature for local development. No binary building required!
Create a Terraform CLI config file at ~/.terraform.d/config.tfrc:
provider_installation {
dev_overrides {
"runpod/runpod" = "./"
}
direct {}
}Then use the provider in your Terraform configuration:
terraform {
required_providers {
runpod = {
source = "runpod/runpod"
}
}
}
provider "runpod" {
api_key = var.runpod_api_key
}If you need to build and use a binary:
go build -o terraform-provider-runpodThen configure Terraform to use the local provider binary:
provider_installation {
filesystem_paths {
paths = ["."]
}
}terraform {
required_providers {
runpod = {
source = "runpod/runpod"
}
}
}
# API key can be set via environment variable RUNPOD_API_KEY
# or in the provider configuration (not shown in this example)
resource "runpod_pod" "demo" {
machine_id = "your-machine-id"
image_name = "runpod/miniconda:py3.10-cuda11.8.0"
gpu_count = 1
start_ssh = true
}Set your RunPod API key as an environment variable:
export RUNPOD_API_KEY="your-api-key-here"Get your API key from RunPod Console
examples/basic/- Basic pod creationexamples/actions/- Pod actionsexamples/datasources/- Data sourcesexamples/machine/- Machine managementexamples/monitoring/- Pod monitoring
The provider schema is defined in terraform-provider-spec.json. To regenerate provider code after modifying the spec:
tfplugingen-framework generate all \
--input terraform-provider-spec.json \
--output internal/providerterraform-provider-runpod/
├── internal/provider/ # Generated code
│ ├── provider_runpod/
│ ├── resource_pod/
│ ├── resource_pod_action/
│ ├── resource_machine/
│ ├── datasource_pod/
│ ├── datasource_machine/
│ └── ...
├── examples/ # Example configurations
├── main.go # Provider entry point
├── plugin.go # Plugin interface
├── go.mod # Go dependencies
└── terraform-provider-spec.json # Provider schema definition
The provider specification is defined in terraform-provider-spec.json and includes:
runpod_pod- Pod managementrunpod_pod_action- Pod actionsrunpod_machine- Machine management
runpod_pod- Pod informationrunpod_machine- Machine informationrunpod_machines- Machine listingrunpod_gpu_types- GPU typesrunpod_data_centers- Data centersrunpod_user- User info
MIT