Skip to main content
The Runpod Terraform provider support is currently in beta. Join our Discord to provide feedback and get support.
The Runpod Terraform provider lets you manage Runpod infrastructure declaratively using HashiCorp Terraform. Define pods, serverless endpoints, templates, and machines in HCL configuration files, apply them with terraform apply, and track state like any other Terraform-managed resource.

Prerequisites

Install and configure

Add the provider to your configuration

Create a main.tf file and declare the Runpod provider:

Set your API key

The recommended approach is to pass your API key as an environment variable so it stays out of your configuration files:
Or declare it as a Terraform variable and pass it at apply time:

Initialize and apply


Quick example: create a pod

This example creates a GPU pod running Miniconda with SSH enabled:

Resources

runpod_pod

Creates and manages a Runpod pod.
Arguments Attributes (read-only)

runpod_pod_action

Performs an action on an existing pod. Use this to stop, resume, terminate, or reset a pod without destroying and recreating it.
Arguments Attributes (read-only)

runpod_template

Creates and manages a reusable pod template. Templates let you define a standard configuration (image, environment variables, disk, ports) once and reuse it across multiple pods or endpoints.
Arguments Attributes (read-only)

runpod_endpoint

Creates and manages a serverless endpoint. Endpoints auto-scale workers based on demand.
Arguments Attributes (read-only)

runpod_machine

Manages a machine listing. Primarily used by host providers to list machines and set pricing.
Arguments Attributes (read-only)

Data sources

runpod_gpu_types

Lists all available GPU types with pricing information.
Attributes

runpod_data_centers

Lists all available data centers.
Attributes

runpod_pod

Retrieves information about an existing pod by ID.
Arguments

runpod_machine

Retrieves information about a specific machine by ID.
Arguments

runpod_machines

Lists machines, optionally filtered by listed status.
Arguments

runpod_template

Retrieves information about a template by ID.
Arguments

runpod_user

Retrieves information about the authenticated user.

Complete example: serverless endpoint

This example creates a template and a serverless endpoint for a vLLM worker, then outputs the endpoint ID.
Run it: