Skip to content

Latest commit

 

History

History
172 lines (122 loc) · 2.62 KB

File metadata and controls

172 lines (122 loc) · 2.62 KB

RunPod Terraform Provider v0.1.0

An official Terraform provider for managing RunPod GPU cloud resources.

Installation

From Terraform Registry

terraform {
  required_providers {
    runpod = {
      source  = "runpod/runpod"
      version = "~> 0.1.0"
    }
  }
}

From Local Files

terraform {
  required_providers {
    runpod = {
      source  = "hashicorp/runpod"
      version = "0.1.0"
    }
  }
}

Configuration

provider "runpod" {
  api_key   = var.runpod_api_key
  endpoint  = "https://api.runpod.io/graphql"  # Optional, defaults to prod
}

Resources

runpod_pod

Deploy and manage RunPod pods (compute instances).

resource "runpod_pod" "example" {
  name                  = "my-pod"
  pod_template_id       = "template-id"
  container_disk_size_gb = 10
  min_memory            = 8
  min_gpu               = 1
  gpu_types             = "RTX,A100"
  cloud_type            = "ALL"
  wait_for_gpu          = true

  env = jsonencode({
    ENVIRONMENT = "production"
  })

  port = "8080:8080"
  command = "python app.py"
}

runpod_machine

Create and manage dedicated GPU machines.

resource "runpod_machine" "example" {
  name        = "training-machine"
  description = "Dedicated machine for ML"
  gpu_count   = 4
  gpu_type    = "A100"
  cpu_count   = 32
  memory_gb   = 256
  disk_gb     = 1000
  region      = "US_EAST"
}

runpod_pod_action

Perform actions on pods (stop/resume/restart/terminate).

resource "runpod_pod_action" "example" {
  pod_id   = runpod_pod.example.id
  action   = "stop"  # stop, resume, restart, terminate
}

Data Sources

runpod_gpu_types

List available GPU types.

data "runpod_gpu_types" "available" {}

runpod_data_centers

List data centers.

data "runpod_data_centers" "available" {}

runpod_machine

Get single machine by ID.

data "runpod_machine" "example" {
  machine_id = "machine-id"
}

runpod_machines

List all machines.

data "runpod_machines" "available" {}

runpod_pod

Get single pod by ID.

data "runpod_pod" "example" {
  pod_id = "pod-id"
}

runpod_user

Get current user info.

data "runpod_user" "current" {}

Authentication

The provider uses API key authentication. Get your API key from the RunPod console at https://www.runpod.io/console/user/settings.

Development

# Build the provider
go build -o terraform-provider-runpod

# Test
go test ./...

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.