Terraform is an infrastructure as code tool that lets you create, update, and version infrastructure by defining resources in configuration files. This allows for a repeated workflow for provisioning and managing your infrastructure. This page describes how to use the Terraform Provider for Pinecone to manage Pinecone indexes, collections, API keys, and projects.

Requirements

Ensure you have the following:

Install the provider

  1. Configuring the Pinecone provider in your Terraform configuration file:
    terraform { 
      required_providers { 
        pinecone = { 
          source = "pinecone-io/pinecone" 
          version = "~> 2.0.0"
        } 
      } 
    } 
    
  2. Run terraform init to install the provider from the Terraform registry. Alternatively, you can download the latest binary for your target platfrom the GitHub repository.

Authenticate

For managing indexes and collections, you authenticate with a Pinecone API key. For managing API keys and projects, you authenticate with Pinecone service account credentials (client ID and client secret).
  1. Set environment variables for authentication:
    # For indexes and collections  
    export PINECONE_API_KEY="YOUR_API_KEY"
    
    # For API keys and projects
    export PINECONE_CLIENT_ID="YOUR_CLIENT_ID"
    export PINECONE_CLIENT_SECRET="YOUR_CLIENT_SECRET"
    
  2. Append the following to your Terraform configuration file:
    provider "pinecone" {}
    
You can also set the API key and/or service account credential as input variables.

Manage resources

The Terraform Provider for Pinecone allows Terraform to manage indexes, collections, API keys, and projects.

Indexes

The pinecone_index resource lets you create, update, and delete indexes.
You can update only the index deletion protection, tags, and integrated inference embedding settings of an index.
# Dense index
resource "pinecone_index" "example-index" {
  name = "example-index"
  dimension = 1536
  metric = "cosine"
  vector_type = "dense"
  spec = {
    serverless = {
      cloud = "aws"
      region = "us-west-2"
    }
  }
  deletion_protection = "disabled"
  tags = {
    environment = "development"
  }
}

# Dense index with integrated embedding
resource "pinecone_index" "example-index-integrated" {
  name = "example-index-integrated"
  spec = {
    serverless = {
      cloud = "aws"
      region = "us-west-2"
    }
  }
  embed = {
    model = "llama-text-embed-v2"
    field_map = {
      text = "chunk_text"
    }
  }
}

Collections

The pinecone_collection resource lets you create and delete collections for pod-based indexes.
resource "pinecone_index" "example-index" {
  name = "example-index"
  dimension = 10
  spec = {
    pod = {
      environment = "us-west4-gcp"
      pod_type = "s1.x1"
    }
  }
}

resource "pinecone_collection" "example-collection" {
  name = "example-collection"
  source = pinecone_index.example-index.name

API keys

The pinecone_api_key resource lets you create, update, and delete API keys.
You can update only the name and roles of an API key.
# API key with default roles (ProjectEditor)
resource "pinecone_api_key" "example-key" {
  name = "example-key"
  project_id = "YOUR_PROJECT_ID"
}

# API key with custom roles
resource "pinecone_api_key" "example-key-custom_roles" {
  name = "example-key-custom-roles"
  project_id = "YOUR_PROJECT_ID"
  roles = ["ProjectViewer", "DataPlaneViewer"]
}

output "api_key_roles" {
  description = "The roles assigned to the API key"
  value       = pinecone_api_key.example.roles
}

Projects

The pinecone_project resource lets you create, update, and delete projects.
Customers who signed up for a Standard or Enterprise plan on or after August 18, 2025 cannot create pod-based indexes and cannot set the max pods for a project.
# Basic project
resource "pinecone_project" "example-project" {
  name = "example-project"
}

# Project with CMEK encryption enabled
resource "pinecone_project" "example-project-encrypted" {
  name = "example-project-encrypted"
  force_encryption_with_cmek = true
}

# Project with custom max pods
resource "pinecone_project" "example-project-custom-pods" {
  name = "example-project-custom-pods"
  max_pods = 10
}

Limitations

The Terraform Provider for Pinecone does not support the following resources:

See also