Requirements
- Terraform 1.6 or later.
- A Runpod account with a Runpod API key.
Install the provider
Create a directory for your configuration and add amain.tf file that declares the Runpod provider:
main.tf
~> 2.0 installs 2.0.0 and any later 2.x release, and blocks an automatic move to 3.0.
Download the provider into your working directory:
.terraform.lock.hcl. Commit that file so everyone on your team uses the same version. To move to a newer release within your constraint, run terraform init -upgrade.
Authenticate
The provider needs a Runpod API key. It reads the key from theapi_key argument first, then falls back to the RUNPOD_API_KEY environment variable. If neither is set, Terraform stops with an error when it configures the provider.
Use an environment variable
Setting the key as an environment variable keeps it out of your configuration files and state. This is the recommended method:provider "runpod" {}.
Use a provider argument
To pass the key through Terraform instead, declare a sensitive variable and reference it in the provider block:main.tf
terraform apply -var="runpod_api_key=YOUR_API_KEY" or a TF_VAR_runpod_api_key environment variable. Never commit the key to a .tfvars file in version control.
The provider sends requests to the production Runpod API by default. To target a different host, set the
base_url argument or the RUNPOD_API_BASE_URL environment variable. Most users never need this setting. The deprecated GraphQL shims use a separate graphql_url setting. See Which Runpod APIs the provider uses.Deploy a Pod
This example creates a single GPU Pod running PyTorch and outputs its ID and status.1
Add the Pod to your configuration
Add the following resource and outputs to
main.tf, below the provider block:main.tf
name, image, and a GPU or CPU type are the minimum a Pod needs. ports is a list of PORT/PROTOCOL strings. start_jupyter starts JupyterLab and generates a password, and needs 8888/http in ports. start_ssh needs an SSH key registered on your account. To set environment variables, add an env map.2
Review the plan
Preview what Terraform will create:The plan should show one
runpod_pod to add and nothing to change or destroy.3
Apply the configuration
Create the Pod:Type
yes when prompted. When the apply finishes, Terraform prints the pod_id and pod_status outputs. The Pod also appears on the Pods page of the Runpod console.4
Clean up
When you’re done, remove the Pod so it stops billing:
What the provider manages
The 2.0.0 provider covers these resources:- Pods, including CPU Pods, with
runpod_pod, and one-off Pod actions such as a restart withrunpod_pod_action. - Serverless endpoints with
runpod_serverless_endpoint. - Templates with
runpod_template. - Network volumes with
runpod_network_volume. - Global volumes with
runpod_global_volume. - Container registry credentials and Amazon ECR delegations with
runpod_registryandrunpod_registry_delegation. - Instant Clusters with
runpod_cluster. - Account SSH keys with
runpod_account_ssh_keys. - Host machines with
runpod_machine. This is a deprecated GraphQL shim for Runpod hosts and needs a host account.
Which Runpod APIs the provider uses
The 2.0.0 provider is generated from the Runpod REST API v2, and nearly every resource and data source talks only tohttps://api.runpod.io/v2.
A few deprecated resources, data sources, and attributes still call the GraphQL API because REST v2 has no route for them yet:
- The
runpod_machineresource, therunpod_machineandrunpod_machinesdata sources, and therunpod_userdata source. - A few deprecated attributes on
runpod_pod,runpod_template, andrunpod_serverless_endpoint, such asmachine_idon Pods andreadmeon templates. - Parts of the three 1.x billing data sources (
runpod_billing_pod,runpod_billing_network_volume, andrunpod_billing_endpoint), which otherwise read the v2 billing routes.
runpod_pod_billing, runpod_serverless_billing, and runpod_network_volume_billing) for new configuration.
The provider makes no REST API v1 calls, so the REST v1 retirement on November 15, 2026 doesn’t affect it.
The graphql_url argument (fallback RUNPOD_GRAPHQL_URL) applies only to the GraphQL shims. Leave it unset unless you target a non-production environment. The rest_v1_url argument from the 2.0.0 release candidates is deprecated and ignored. The registries[].username field on runpod_registries is deprecated and always null.
Next steps
- Migrate from the 1.x provider if you have existing 1.x configuration and state.
- Browse the provider reference for every resource and data source.
- Learn about Pod configuration options that map to
runpod_podarguments. - Deploy a Serverless endpoint and manage it with
runpod_serverless_endpoint.