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.

Terraform can manage the configuration of Pinecone resources, including indexes and collections.

Setup guide

This page shows you how to use the Terraform Provider for Pinecone to manage your Pinecone resources.

Overview

The Terraform Provider for Pinecone allows Terraform to manage Pinecone resources. For more code and examples, see the Terraform Provider for Pinecone GitHub repository.

Installation

The provider is registered in the official Terraform registry. This enables the provider to be auto-installed when you run terraform init. You can also download the latest binary for your target platform from the Releases tab.

Enable the provider

The provider needs to be configured with the proper credentials before it can be used. You can create an API key in the console. To avoid exposing credentials, you can provide your credentials by setting the PINECONE_API_KEY environment variable.

You can enable the provider in your Terraform configuration by adding the following to your Terraform configuration file:

terraform { 
  required_providers { 
    pinecone = { 
      source = "pinecone-io/pinecone" 
    } 
  } 
} 
# Configure the provider by environment variable
provider "pinecone" {}

Index Resources

The pinecone_index resource lets you create, delete, and update indexes.


resource "pinecone_index" "test" {
  name       = "tf-test-index"
  dimension  = 1536
  metric     = "cosine"
  spec       = {
    serverless = {
      cloud  = "aws"
      region = "us-west-2"
    }
  }
}

Additional resources

Was this page helpful?