Skip to main content

Getting Started

By the end of this guide, you will be able to create and manage SvectorDB resources using CloudFormation.

You will need to have a SvectorDB account and an AWS account to use this integration.

Enabling SvectorDB in CloudFormation

You will need to enable the SvectorDB CloudFormation resource provider in your AWS account.

We've created a CloudFormation template to make this process easier. You can find the template here. You will need to deploy this template in each region where you want to use SvectorDB resources.

cloudformation-extension-activation.yml

Once deployed, you will see two new resources under the "Activated Extensions" section in the CloudFormation console

Enabling the CloudFormation Integration in SvectorDB

Visit the integrations page in the dashboard and click "AWS CloudFormation". You will need to add your AWS account ID to ensure only accounts you own can use the integration.

In this screen you will also find the integration key that you will need to use in your CloudFormation templates.

For this example my integration key is 530cf7f6-c33f-4e8d-bc17-c14956ab5298 and my AWS account ID is 123456789012.

Creating a database in CloudFormation

To create a new database, use the SvectorDB::VectorDatabase::Database resource type. Here is an example of how:

Resources:
VectorDb:
Type: SvectorDB::VectorDatabase::Database
Properties:
IntegrationId: <INTEGRATION_KEY> # Replace with your integration key
Name: My first database
Metric: EUCLIDEAN
Dimension: 1024
Type: SANDBOX

In this example, we are creating a new database with the name "My first database" and a dimension of 1024. The metric used is the Euclidean distance.

If configured correctly, the database will be created in your SvectorDB account when the CloudFormation stack is created.

Creating an API key in CloudFormation

To access your new database, you will need to create an API key. You can do this using the SvectorDB::VectorDatabase::ApiKey resource type. Here is an example of how:

Resources:
VectorDb:
Type: SvectorDB::VectorDatabase::Database
Properties:
IntegrationId: <INTEGRATION_KEY> # Replace with your integration key
Name: My first database
Metric: EUCLIDEAN
Dimension: 1024
Type: SANDBOX
ApiKey:
Type: SvectorDB::VectorDatabase::ApiKey
Properties:
IntegrationId: <INTEGRATION_KEY> # Replace with your integration key
DatabaseId: !Ref VectorDb

You can use the !Ref function to get the API key for the database. For example, if you want to use the API key in a Lambda function, you can use the !Ref function to get the API key and pass it as an environment variable to the Lambda function.

Resources:
MyLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Handler: ...
Role: ...
Code: ...
Runtime: ...
Environment:
Variables:
SVECTORDB_API_KEY: !Ref ApiKey

Next Steps

For more information on each resource type, see our documentation on SvectorDB::VectorDatabase::Database and SvectorDB::VectorDatabase::ApiKey.

You now know how to use SvectorDB resources in CloudFormation. If you have any questions, feel free to reach out to our support team