Requirements
Ensure you have the following:- Terraform >= v1.4.6
- A Pinecone API key for managing indexes and collections
- A Pinecone service account for managing projects, API keys, service accounts, role bindings, invites, and users
Go >= v1.24 is required only if you build the provider from source. You don’t need Go to install the provider from the Terraform Registry.
Install the provider
-
Configure the Pinecone provider in your Terraform configuration file:
-
Append the following to your Terraform configuration file:
dimension defaults to the model’s dimension. The model can’t be changed once set, but you can update field_map, read_parameters, and write_parameters. The read-only embed.effective_read_parameters and embed.effective_write_parameters attributes report the parameters the API applied, including server-side defaults you didn’t set.
You can update only the deletion protection, tags, integrated inference embedding settings, and read capacity of an index. Changing any other attribute — including
name, dimension, metric, the cloud and region, or the metadata schema — replaces the index.BYOC indexes
To create a BYOC index, setspec.byoc.environment to the environment identifier Pinecone provides for your deployment:
Pod-based indexes
To create a pod-based index, setspec.pod:
Read capacity
Serverless and BYOC indexes support configurable read capacity throughread_capacity inside the serverless or byoc spec. There are two modes: on_demand, which is the default, and dedicated, which provisions dedicated read nodes.
node_type to b1 or t1. The first time you switch an index to dedicated mode, node_type, replicas, and shards are all required.
Metadata schema
Serverless and BYOC indexes support aschema block that controls metadata indexing. By default, all metadata is indexed. When schema is present, only the fields you list with filterable = true are indexed.
Timeouts
Index creation and deletion both time out after 5 minutes by default. To override this, set atimeouts block:
Collections
Thepinecone_collection resource lets you create and delete collections for pod-based indexes. Set source to the name of the source index.
timeouts block, with the same 5-minute defaults as indexes.
Projects
Thepinecone_project resource lets you create, update, and delete projects. Once force_encryption_with_cmek is enabled, it can’t be disabled. max_pods defaults to 0, which allows serverless indexes only.
Customers on those plans also can’t set max_pods for a project.
API keys
Thepinecone_api_key resource lets you create, update, and delete API keys. Valid roles values are ProjectEditor, ProjectViewer, ControlPlaneEditor, ControlPlaneViewer, DataPlaneEditor, and DataPlaneViewer. roles defaults to ["ProjectEditor"].
You can update only the name and roles of an API key.
project_id is required when you create a key.Service accounts
Thepinecone_service_account resource lets you create, update, and delete service accounts. A service account authenticates with an OAuth client ID and secret. Grant it roles with a role binding.
rotate_trigger from one non-empty value to another. Setting it for the first time, or clearing it, establishes a baseline without rotating, so an existing credential is never invalidated unintentionally.
Role bindings
Thepinecone_role_binding resource lets you grant a role to a principal at organization or project scope. For details on the role model, see Manage roles and access.
- Set
principal_typetouser,service_account, orapi_key, andprincipal_idto that principal’s ID. - Set
resource_typetoorganizationorproject. For project scope,resource_idis required and must be the project ID. For organization scope, omitresource_id. The binding applies to the caller’s organization. - Organization-scoped
rolevalues areOrgOwner,OrgManager,OrgBillingAdmin, andOrgMember. Project-scoped values areProjectOwner,ProjectManager,ProjectMember,ProjectEditor,ProjectViewer,ControlPlaneEditor,ControlPlaneViewer,DataPlaneEditor, andDataPlaneViewer.
Role bindings are immutable. Changing any attribute revokes the existing binding and creates a new one.
pinecone_role_binding resource doesn’t accept principal_type = "invite". Pinecone moves an invite’s bindings to the user principal when the invite is accepted, so Terraform can’t manage them across that transition. To grant roles to someone who hasn’t joined your organization yet, use pinecone_invite, then manage their roles here with principal_type = "user" once they accept. The pinecone_role_bindings data source does accept invite, so you can still read what a pending invite granted.
Invites
Thepinecone_invite resource manages an organization invitation, not the resulting membership. Creating it sends an invite to the given email with a set of initial roles. Deleting it revokes an invite that is still pending. The role_bindings list must include at least one organization-scoped role that grants membership.
status attribute reports pending, expired, or processed. Invites expire 7 days after creation, and the provider doesn’t expose a way to change that. Once an invite is accepted, its status is processed and Terraform stops acting on it. Destroying an accepted invite is a no-op.
Pinecone doesn’t return the roles an invite granted, so
role_bindings is applied only at creation. Terraform can’t detect drift on it or recover it on import. To read the bindings, use the pinecone_role_bindings data source with principal_type = "invite".Users
Thepinecone_user resource manages an existing organization member. You can’t create or update users through Terraform. They join your organization by accepting an invite. Bring an existing user under management with terraform import. To change a user’s roles, use a role binding.
id attribute is immutable. To manage a different user, run terraform state rm on this resource and import the intended one.
Read existing resources
Data sources let you read resources that Terraform doesn’t manage. Most resource types have a singular data source that fetches one object and a plural data source that lists many.- For
pinecone_user, set exactly one ofidoremail. Email matching is case-insensitive. - For
pinecone_role_bindings,principal_typeis required when you setprincipal_id, andresource_typeis required when you setresource_id. You can’t filter by a binding’s own ID. Fetch it with thepinecone_role_bindingdata source instead. pinecone_invitesreturns onlypendingandexpiredinvites. To read an accepted invite, fetch it by ID withpinecone_invite.- The service account data sources never return client secrets.
Import existing resources
All resources support theterraform import command:
For example:
pinecone_api_key.keyandpinecone_service_account.client_secretstay empty in state for an imported resource. To issue and store a new service account secret, changerotate_trigger.pinecone_invite.role_bindingsstays empty in state, and Terraform proposes a replacement on the next plan until you set it to match the original invite. Use thepinecone_role_bindingsdata source withprincipal_type = "invite"to see what the invite granted.
Limitations
The Terraform Provider for Pinecone doesn’t support the following:- Backups for serverless indexes
- Private endpoints
- Assistants
- BYOC environment provisioning (you reference an existing environment by its identifier, which Pinecone provisions for you).
- Full-text search fields (the index
schemablock accepts onlyfilterable, so you can’t configure fields for full-text search).
See also
- Documentation can be found on the Terraform Registry.
- See the GitHub repository for additional usage examples.
- For support requests, create an issue in the GitHub repository.