amazonaurora

package
v0.1.314 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

Amazon Aurora Vector Store Construct Library

---

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Language Package
Typescript Logo TypeScript @cdklabs/generative-ai-cdk-constructs
Python Logo Python cdklabs.generative_ai_cdk_constructs
Java Logo Java io.github.cdklabs.generative_ai_cdk_constructs
.Net .Net CdkLabs.GenerativeAICdkConstructs
Go Go github.com/cdklabs/generative-ai-cdk-constructs-go/generative-ai-cdk-constructs

This construct library provides a class that defines a AmazonAuroraVectorStore construct for an Amazon Aurora to be used for a vector store for a Knowledge Base. Additionally, you can utilize fromExistingAuroraVectorStore() method to use your existing Aurora database as a vector DB. AmazonAuroraVectorStore is an L3 resource that creates a VPC with 3 subnets (public, private with NAT Gateway, private without NAT Gateway) and Amazon Aurora Serverless V2 Cluster. The cluster has 1 writer/reader instance with latest supported PostgreSQL version (currently it is 15.5) and having the following cofiguration: min capacity 0.5, max capacity 4. Lambda custom resource executes required pgvector and Amazon Bedrock Knowledge Base SQL queries (see more here) against Aurora cluster during deployment. The secret containing databases credentials is being deployed and securely stored in AWS Secrets Manager. You must specify the same embeddings model that you are going to use in KnowledgeBase construct. Due to the nature of provisioning RDS cluster it takes a long time (over 20-25 minutes) to both deploying and destroying construct so please take this in consideration.

Table of contents

API

See the API documentation.

Amazon Aurora Vector Store

TypeScript

amazonaurora.NewAmazonAuroraVectorStore(this, jsii.String("AuroraVectorStore"), &AmazonAuroraVectorStoreProps{
	EmbeddingsModelVectorDimension: bedrock.BedrockFoundationModel_COHERE_EMBED_ENGLISH_V3().VectorDimensions,
})

fromExistingAuroraVectorStore()

You can import your existing Aurora DB to be used as a vector DB for a knowledge base. Note - you need to provide clusterIdentifier, databaseName, vpc, secret and auroraSecurityGroupName used in deployment of your existing RDS Amazon Aurora DB, as well as embeddingsModel that you want to be used by a Knowledge Base for chunking. Additionally, your stack's env needs to contain region and account variables.

TypeScript

auroraDb := amazonaurora.AmazonAuroraVectorStore_FromExistingAuroraVectorStore(this, jsii.String("ExistingAuroraVectorStore"), &ExistingAmazonAuroraVectorStoreProps{
	ClusterIdentifier: jsii.String("aurora-serverless-vector-cluster"),
	DatabaseName: jsii.String("bedrock_vector_db"),
	SchemaName: jsii.String("bedrock_integration"),
	TableName: jsii.String("bedrock_kb"),
	VectorField: jsii.String("embedding"),
	TextField: jsii.String("chunks"),
	MetadataField: jsii.String("metadata"),
	PrimaryKeyField: jsii.String("id"),
	EmbeddingsModelVectorDimension: bedrock.BedrockFoundationModel_COHERE_EMBED_ENGLISH_V3().VectorDimensions,
	Vpc: aws_ec2.Vpc_FromLookup(this, jsii.String("VPC"), &VpcLookupOptions{
		VpcId: jsii.String("vpc-0c1a234567ee8bc90"),
	}),
	AuroraSecurityGroup: aws_ec2.SecurityGroup_FromSecurityGroupId(this, jsii.String("AuroraSecurityGroup"), jsii.String("sg-012456789")),
	Secret: aws_rds.DatabaseSecret_FromSecretCompleteArn(this, jsii.String("Secret"), cdk.Stack_Of(this).FormatArn(&ArnComponents{
		Service: jsii.String("secretsmanager"),
		Resource: jsii.String("secret"),
		ResourceName: jsii.String("rds-db-credentials/cluster-1234567890"),
		Region: cdk.Stack_*Of(this).Region,
		Account: cdk.Stack_*Of(this).Account,
		ArnFormat: cdk.ArnFormat_COLON_RESOURCE_NAME,
	})),
})

kb := bedrock.NewVectorKnowledgeBase(this, jsii.String("KnowledgeBase"), &VectorKnowledgeBaseProps{
	EmbeddingsModel: bedrock.BedrockFoundationModel_COHERE_EMBED_ENGLISH_V3(),
	VectorStore: auroraDb,
	Instruction: jsii.String("Use this knowledge base to answer questions about books. " + "It contains the full text of novels."),
})

docBucket := aws_s3.NewBucket(this, jsii.String("DocBucket"))

bedrock.NewS3DataSource(this, jsii.String("DataSource"), &S3DataSourceProps{
	Bucket: docBucket,
	KnowledgeBase: kb,
	DataSourceName: jsii.String("books"),
	ChunkingStrategy: bedrock.ChunkingStrategy_FixedSize(&FixedSizeChunkingConfigurationProperty{
		MaxTokens: jsii.Number(500),
		OverlapPercentage: jsii.Number(20),
	}),
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AmazonAuroraVectorStore_IsConstruct

func AmazonAuroraVectorStore_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func ExistingAmazonAuroraVectorStore_IsConstruct

func ExistingAmazonAuroraVectorStore_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func NewAmazonAuroraVectorStore_Override

func NewAmazonAuroraVectorStore_Override(a AmazonAuroraVectorStore, scope constructs.Construct, id *string, props *AmazonAuroraVectorStoreProps)

Experimental.

func NewExistingAmazonAuroraVectorStore_Override

func NewExistingAmazonAuroraVectorStore_Override(e ExistingAmazonAuroraVectorStore, scope constructs.Construct, id *string, props *ExistingAmazonAuroraVectorStoreProps)

Experimental.

Types

type AmazonAuroraVectorStore

type AmazonAuroraVectorStore interface {
	constructs.Construct
	// The Secret ARN of your Amazon Aurora DB cluster.
	// Experimental.
	CredentialsSecretArn() *string
	// The name of the database for the Aurora Vector Store.
	// Experimental.
	DatabaseName() *string
	// The embeddings model dimension used for the Aurora Vector Store.
	//
	// The vector dimensions of the model must match the dimensions
	// used in the KnowledgeBase construct.
	// Experimental.
	EmbeddingsModelVectorDimension() *float64
	// The field name for the metadata column in the Aurora Vector Store.
	// Experimental.
	MetadataField() *string
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// The primary key field for the Aurora Vector Store table.
	// Experimental.
	PrimaryKeyField() *string
	// The ARN of your Amazon Aurora DB cluster.
	// Experimental.
	ResourceArn() *string
	// The schema name for the Aurora Vector Store.
	// Experimental.
	SchemaName() *string
	// The name of the table for the Aurora Vector Store.
	// Experimental.
	TableName() *string
	// The field name for the text column in the Aurora Vector Store.
	// Experimental.
	TextField() *string
	// The field name for the vector column in the Aurora Vector Store.
	// Experimental.
	VectorField() *string
	// The VPC of your Amazon Aurora DB cluster.
	// Experimental.
	Vpc() awsec2.IVpc
	// Experimental.
	AddIngressRuleToAuroraSecurityGroup(lambdaSecurityGroup awsec2.ISecurityGroup, auroraSecurityGroup awsec2.ISecurityGroup)
	// Experimental.
	CreateAuroraPgCRPolicy(clusterIdentifier *string) awsiam.ManagedPolicy
	// Experimental.
	CreateLambdaSecurityGroup(vpc awsec2.IVpc) awsec2.SecurityGroup
	// Experimental.
	GenerateResourceArn(clusterIdentifier *string) *string
	// Experimental.
	SetupCustomResource(databaseClusterResources *DatabaseClusterResources, lambdaSecurityGroup awsec2.SecurityGroup, auroraPgCRPolicy awsiam.ManagedPolicy) awscdk.CustomResource
	// Experimental.
	SetupDatabaseClusterResources(vpc awsec2.IVpc, secret awssecretsmanager.ISecret, clusterIdentifier *string, auroraSecurityGroup awsec2.ISecurityGroup) *DatabaseClusterResources
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

Experimental.

func NewAmazonAuroraVectorStore

func NewAmazonAuroraVectorStore(scope constructs.Construct, id *string, props *AmazonAuroraVectorStoreProps) AmazonAuroraVectorStore

Experimental.

type AmazonAuroraVectorStoreProps

type AmazonAuroraVectorStoreProps struct {
	// The embeddings model dimension used for the Aurora Vector Store.
	//
	// The vector dimensions of the model must match the dimensions
	// used in the KnowledgeBase construct.
	// Experimental.
	EmbeddingsModelVectorDimension *float64 `field:"required" json:"embeddingsModelVectorDimension" yaml:"embeddingsModelVectorDimension"`
	// The field name for the metadata column in the Aurora Vector Store.
	// Experimental.
	MetadataField *string `field:"optional" json:"metadataField" yaml:"metadataField"`
	// The primary key field for the Aurora Vector Store table.
	// Experimental.
	PrimaryKeyField *string `field:"optional" json:"primaryKeyField" yaml:"primaryKeyField"`
	// The schema name for the Aurora Vector Store.
	// Experimental.
	SchemaName *string `field:"optional" json:"schemaName" yaml:"schemaName"`
	// The name of the table for the Aurora Vector Store.
	// Experimental.
	TableName *string `field:"optional" json:"tableName" yaml:"tableName"`
	// The field name for the text column in the Aurora Vector Store.
	// Experimental.
	TextField *string `field:"optional" json:"textField" yaml:"textField"`
	// The field name for the vector column in the Aurora Vector Store.
	// Experimental.
	VectorField *string `field:"optional" json:"vectorField" yaml:"vectorField"`
	// Cluster identifier.
	// Experimental.
	ClusterId *string `field:"optional" json:"clusterId" yaml:"clusterId"`
	// The name of the database for the Aurora Vector Store.
	// Experimental.
	DatabaseName *string `field:"optional" json:"databaseName" yaml:"databaseName"`
	// The version of PostgreSQL to use for the Aurora Vector Store.
	//
	// By default, the latest supported version will be used.
	// Experimental.
	PostgreSQLVersion awsrds.AuroraPostgresEngineVersion `field:"optional" json:"postgreSQLVersion" yaml:"postgreSQLVersion"`
	// User's VPC in which they want to deploy Aurora Database.
	// Experimental.
	Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
}

Properties for configuring an Amazon Aurora Vector Store. Experimental.

type BaseAuroraVectorStoreProps

type BaseAuroraVectorStoreProps struct {
	// The embeddings model dimension used for the Aurora Vector Store.
	//
	// The vector dimensions of the model must match the dimensions
	// used in the KnowledgeBase construct.
	// Experimental.
	EmbeddingsModelVectorDimension *float64 `field:"required" json:"embeddingsModelVectorDimension" yaml:"embeddingsModelVectorDimension"`
	// The field name for the metadata column in the Aurora Vector Store.
	// Experimental.
	MetadataField *string `field:"optional" json:"metadataField" yaml:"metadataField"`
	// The primary key field for the Aurora Vector Store table.
	// Experimental.
	PrimaryKeyField *string `field:"optional" json:"primaryKeyField" yaml:"primaryKeyField"`
	// The schema name for the Aurora Vector Store.
	// Experimental.
	SchemaName *string `field:"optional" json:"schemaName" yaml:"schemaName"`
	// The name of the table for the Aurora Vector Store.
	// Experimental.
	TableName *string `field:"optional" json:"tableName" yaml:"tableName"`
	// The field name for the text column in the Aurora Vector Store.
	// Experimental.
	TextField *string `field:"optional" json:"textField" yaml:"textField"`
	// The field name for the vector column in the Aurora Vector Store.
	// Experimental.
	VectorField *string `field:"optional" json:"vectorField" yaml:"vectorField"`
}

Base properties for an Aurora Vector Store. Experimental.

type DatabaseClusterResources

type DatabaseClusterResources struct {
	// The security group associated with the Aurora cluster.
	// Experimental.
	AuroraSecurityGroup awsec2.ISecurityGroup `field:"required" json:"auroraSecurityGroup" yaml:"auroraSecurityGroup"`
	// The unique cluster identifier of the Aurora RDS cluster.
	// Experimental.
	ClusterIdentifier *string `field:"required" json:"clusterIdentifier" yaml:"clusterIdentifier"`
	// The ARN of your existing Amazon Aurora DB cluster.
	// Experimental.
	ResourceArn *string `field:"required" json:"resourceArn" yaml:"resourceArn"`
	// The secret containing the database credentials.
	//
	// The secret must contain `username` and `password` values.
	// Experimental.
	Secret awssecretsmanager.ISecret `field:"required" json:"secret" yaml:"secret"`
	// The VPC in which the database cluster is located.
	// Experimental.
	Vpc awsec2.IVpc `field:"required" json:"vpc" yaml:"vpc"`
	// The Amazon Aurora RDS cluster.
	// Experimental.
	AuroraCluster awsrds.DatabaseCluster `field:"optional" json:"auroraCluster" yaml:"auroraCluster"`
}

Interface representing the resources required for a database cluster. Experimental.

type ExistingAmazonAuroraVectorStore

type ExistingAmazonAuroraVectorStore interface {
	constructs.Construct
	// The Secret ARN of your Amazon Aurora DB cluster.
	// Experimental.
	CredentialsSecretArn() *string
	// The name of the database for the Aurora Vector Store.
	// Experimental.
	DatabaseName() *string
	// The embeddings model dimension used for the Aurora Vector Store.
	//
	// The vector dimensions of the model must match the dimensions
	// used in the KnowledgeBase construct.
	// Experimental.
	EmbeddingsModelVectorDimension() *float64
	// The field name for the metadata column in the Aurora Vector Store.
	// Experimental.
	MetadataField() *string
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// The primary key field for the Aurora Vector Store table.
	// Experimental.
	PrimaryKeyField() *string
	// The ARN of your Amazon Aurora DB cluster.
	// Experimental.
	ResourceArn() *string
	// The schema name for the Aurora Vector Store.
	// Experimental.
	SchemaName() *string
	// The name of the table for the Aurora Vector Store.
	// Experimental.
	TableName() *string
	// The field name for the text column in the Aurora Vector Store.
	// Experimental.
	TextField() *string
	// The field name for the vector column in the Aurora Vector Store.
	// Experimental.
	VectorField() *string
	// The VPC of your Amazon Aurora DB cluster.
	// Experimental.
	Vpc() awsec2.IVpc
	// Experimental.
	AddIngressRuleToAuroraSecurityGroup(lambdaSecurityGroup awsec2.ISecurityGroup, auroraSecurityGroup awsec2.ISecurityGroup)
	// Experimental.
	CreateAuroraPgCRPolicy(clusterIdentifier *string) awsiam.ManagedPolicy
	// Experimental.
	CreateLambdaSecurityGroup(vpc awsec2.IVpc) awsec2.SecurityGroup
	// Experimental.
	GenerateResourceArn(clusterIdentifier *string) *string
	// Experimental.
	SetupCustomResource(databaseClusterResources *DatabaseClusterResources, lambdaSecurityGroup awsec2.SecurityGroup, auroraPgCRPolicy awsiam.ManagedPolicy) awscdk.CustomResource
	// Experimental.
	SetupDatabaseClusterResources(vpc awsec2.IVpc, secret awssecretsmanager.ISecret, clusterIdentifier *string, auroraSecurityGroup awsec2.ISecurityGroup) *DatabaseClusterResources
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

Experimental.

func AmazonAuroraVectorStore_FromExistingAuroraVectorStore

func AmazonAuroraVectorStore_FromExistingAuroraVectorStore(scope constructs.Construct, id *string, props *ExistingAmazonAuroraVectorStoreProps) ExistingAmazonAuroraVectorStore

Creates an instance of AmazonAuroraVectorStore using existing Aurora Vector Store properties.

You need to provide your existing Aurora Vector Store properties such as `databaseName`, `clusterIdentifier`, `vpc` where database is deployed, `secret` containing username and password for authentication to database, and `auroraSecurityGroup` with the ecurity group that was used for the database.

Returns: An instance of AmazonAuroraVectorStore. Experimental.

func NewExistingAmazonAuroraVectorStore

func NewExistingAmazonAuroraVectorStore(scope constructs.Construct, id *string, props *ExistingAmazonAuroraVectorStoreProps) ExistingAmazonAuroraVectorStore

Experimental.

type ExistingAmazonAuroraVectorStoreProps

type ExistingAmazonAuroraVectorStoreProps struct {
	// The embeddings model dimension used for the Aurora Vector Store.
	//
	// The vector dimensions of the model must match the dimensions
	// used in the KnowledgeBase construct.
	// Experimental.
	EmbeddingsModelVectorDimension *float64 `field:"required" json:"embeddingsModelVectorDimension" yaml:"embeddingsModelVectorDimension"`
	// The field name for the metadata column in the Aurora Vector Store.
	// Experimental.
	MetadataField *string `field:"optional" json:"metadataField" yaml:"metadataField"`
	// The primary key field for the Aurora Vector Store table.
	// Experimental.
	PrimaryKeyField *string `field:"optional" json:"primaryKeyField" yaml:"primaryKeyField"`
	// The schema name for the Aurora Vector Store.
	// Experimental.
	SchemaName *string `field:"optional" json:"schemaName" yaml:"schemaName"`
	// The name of the table for the Aurora Vector Store.
	// Experimental.
	TableName *string `field:"optional" json:"tableName" yaml:"tableName"`
	// The field name for the text column in the Aurora Vector Store.
	// Experimental.
	TextField *string `field:"optional" json:"textField" yaml:"textField"`
	// The field name for the vector column in the Aurora Vector Store.
	// Experimental.
	VectorField *string `field:"optional" json:"vectorField" yaml:"vectorField"`
	// The Security group associated with the RDS Aurora instance.
	//
	// This security group allows access to the Aurora Vector Store from Lambda's
	// custom resource running pgVector SQL commands.
	// Experimental.
	AuroraSecurityGroup awsec2.ISecurityGroup `field:"required" json:"auroraSecurityGroup" yaml:"auroraSecurityGroup"`
	// The unique cluster identifier of your Aurora RDS cluster.
	// Experimental.
	ClusterIdentifier *string `field:"required" json:"clusterIdentifier" yaml:"clusterIdentifier"`
	// The name of the database for the Aurora Vector Store.
	// Experimental.
	DatabaseName *string `field:"required" json:"databaseName" yaml:"databaseName"`
	// The secret containing the database credentials.
	//
	// The secret must contain `host`, `port`, `username`,
	// `password` and `dbname` values.
	// Experimental.
	Secret awssecretsmanager.ISecret `field:"required" json:"secret" yaml:"secret"`
	// The VPC in which the existing Aurora Vector Store is located.
	// Experimental.
	Vpc awsec2.IVpc `field:"required" json:"vpc" yaml:"vpc"`
}

Properties for an existing Aurora Vector Store.

You database must have TCP/IP port that the database will use for application connections set up for `5432`. Experimental.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL