Skip to main content

A CDK construct for Pinecone Indexes

Project description

Pinecone DB Icon

Pinecone DB Construct for AWS CDK

CI NPM version PyPI version License

The Pinecone DB Construct for AWS CDK is a JSII-constructed library that simplifies the creation and management of Pinecone indexes in your AWS infrastructure. It allows you to define, configure, and orchestrate your vector database resources alongside your AWS resources within your CDK application.

Features

  • Define Pinecone index configurations in code using familiar AWS CDK constructs.
  • Automate the setup and configuration of Pinecone resources with AWS Lambda and AWS Secrets Manager.
  • Seamlessly integrate Pinecone DB into your cloud-native applications.
  • Supports ARM serverless for deployments

Installation

Install this construct library using npm or pip, depending on your development language:

For TypeScript/JavaScript users:

npm install pinecone-db-construct

For Python users:

pip install pinecone-db-construct

Usage

TypeScript

Below is an example demonstrating how to use the Pinecone DB Construct in a TypeScript CDK application:

import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { PineconeIndex, PineConeEnvironment } from '../index';

class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new PineconeIndex(
      this,
      'PineconeIndex',
      {
        indexSettings: [{
          apiKeySecretName: 'pinecone-test',
          environment: PineConeEnvironment.GCP_STARTER,
          dimension: 128,
          removalPolicy: RemovalPolicy.SNAPSHOT,
        }],
        customResourceSettings: {
          numAttemptsToRetryOperation: 2,
        },
      },
    );
  }
}

const APP = new App();

new MyStack(APP, 'MyStack');

APP.synth();

Python

For CDK applications written in Python, you can use the construct as shown:

from aws_cdk import (
    App,
    RemovalPolicy,
    Stack,
    StackProps
)
from constructs import Construct
from pinecone_db_construct import PineconeIndex, PineConeEnvironment  # Assuming these exist in the ../index file relative to this file

class MyStack(Stack):
    def __init__(self, scope: Construct, id: str, props: StackProps = None):
        super().__init__(scope, id, props)

        PineconeIndex(
            self,
            'PineconeIndex',
            index_settings=[{
                'api_key_secret_name': 'pinecone-test',
                'environment': PineConeEnvironment.GCP_STARTER,
                'dimension': 128,
                'removal_policy': RemovalPolicy.SNAPSHOT,
            }],
            custom_resource_settings={
                'num_attempts_to_retry_operation': 2,
            }
        )

APP = App()

MyStack(APP, 'MyStack')

APP.synth()

Common Issues

If running the default ARM deployment architecture and deploying on an x86_64 machine, you may run into the dreaded exec /bin/sh: exec format error, if this happens you have two options:

  1. Switch to x86 architecture (Lame 😒):
new PineconeIndex(
this,
'PineconeIndex',
{
  deploymentSettings: {
    deploymentArchitecture: lambda.Architecture.X86_64,
  },
  .
  .
  .
})
  1. Allow docker to emulate ARM (Better 💪):
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Note: first time bundling will be slower when running in emulation mode, so keep that in mind (adds about 40 sec for first time deployment). Most most CICD environments will do this for you (github actions) with do this emulation out of the box for you.

Contributing

We welcome contributions, feedback, and bug reports. Before you contribute, please read our contributing guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinecone-db-construct-0.0.6.tar.gz (60.1 kB view hashes)

Uploaded Source

Built Distribution

pinecone_db_construct-0.0.6-py3-none-any.whl (58.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page