Skip to content

Implement new Index resource features - bump go-pinecone and other deps #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Apr 19, 2025

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Mar 20, 2025

Problem

It has been a long while since we've updated the terraform provider, and the go-pinecone client the provider depends on has seen several major version bumps since then.

There are a number of new index features the provider does not currently support:

  • Deletion protection
  • Index tags
  • Sparse / Dense indexes
  • Integrated inference

There are also a number of other dependencies that could use updating, as dependabot has dutifully let us know:

Solution

  • Bump go-pinecone to the latest version: v3.1.0
  • Bump various dependencies around the terraform-plugin-framework and go (see the list above).
  • Update index resource and data source schemas to support new index configurations: deletion_protection, tags, embed, and vector_type.
  • Previously, the IndexResource Update method was basically a noop, this has now been updated to support updating index tags, deletion_protection, and embed properties. Check out the Update method in index_resource.go for specifics on how this is handled.
  • The IndexResource Create method also has a lot of changes to support creating various index types.
  • The schemas for both IndexDataSource and IndexResource have been updated to include all of the new index configuration fields. For context: in terraform a "resource" is the managed thing you're creating / updating, and a data source is a "read only" representation of that thing.
  • I've done an overhaul on how we're testing some things in index_resource_test.go, and a few other places. This was primarily to cover certain error cases and the full flow from create -> update -> destroy for indexes.
  • Collections are unchanged in this update.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

You'll need to install the terraform CLI locally. Easiest way is probably through brew:

brew tap hashicorp/tap
brew install hashicorp/tap/terraform
terraform -version

After installing terraform, find your ~/.terraformrc file, clone this repo, and add a dev override for wherever you've built the provider binary locally. It should look something like this:

provider_installation {
	dev_overrides {
		"pinecone-io/pinecone" = "/Users/austin/workspace/terraform-provider-pinecone"
	}

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}

Create a folder for testing the locally built provider from the cloned repo, and add a new hcl file (something like main.tf):

mkdir pinecone-terraform-test
cd pinecone-terraform-test
touch main.tf

Update the main.tf file with your desired configuration. For example, here's a serverless integrated index:

terraform {
  required_providers {
    pinecone = {
      source = "pinecone-io/pinecone"
    }
  }
}

provider "pinecone" {
}

resource "pinecone_index" "testsls" {
  name = "tftestslsindex22"
  deletion_protection = "disabled"
  metric = "cosine"
  spec = {
    serverless = {
      cloud = "aws"
      region = "us-west-2"
    }
  }
  tags = {
    test = "test1"
    blah = "foo"
  }
  embed = {
    model = "multilingual-e5-large"
    field_map = {
      text = "chunk_text"
    }
  }
}

Once you've updated your main.tf file, you can run the following:

# generally only need to init the first time with a new tf file
terraform init 
# plan will give you a preview of the resource you're about to create or update
terraform plan 
# apply will actually create or update the thing
terraform apply

From there you can make changes to the resource, or add new resources to the configuration file and rerun terraform plan / terraform apply. Use the Pinecone console to validate the external resource is created and updated as expected.


…x in order to support deletion_protection and tags for index resources, update/cleanup index resource acceptance tests
…g CreateIndexForModel when needed, validate fields in spec against type of index being created
@austin-denoble austin-denoble changed the title Bump go-pinecone to v3.1.0 - Implement new Index features Implement new Index resource features - bump go-pinecone and other deps Apr 15, 2025
Copy link

@jhamon jhamon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs stuff looks good. I didn't look much at the tests, but the rest makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants