11import { Construct } from "constructs"
22import { Role } from "aws-cdk-lib/aws-iam"
3+ import { Tags } from "aws-cdk-lib"
34import {
45 VectorCollection ,
56 VectorCollectionStandbyReplicas
@@ -9,6 +10,7 @@ export interface OpenSearchResourcesProps {
910 readonly stackName : string
1011 readonly bedrockExecutionRole : Role
1112 readonly region : string
13+ readonly collectionName ?: string
1214}
1315
1416export class OpenSearchResources extends Construct {
@@ -19,11 +21,15 @@ export class OpenSearchResources extends Construct {
1921
2022 // Create the OpenSearch Serverless collection using L2 construct
2123 this . collection = new VectorCollection ( this , "Collection" , {
22- collectionName : `${ props . stackName } -vector-db` ,
24+ collectionName : props . collectionName ?? `${ props . stackName } -vector-db` ,
2325 description : "EPS Assist Vector Store" ,
2426 standbyReplicas : VectorCollectionStandbyReplicas . DISABLED
2527 } )
2628
29+ // set static values for commit and version tags to stop it being recreated
30+ Tags . of ( this . collection ) . add ( "commit" , "static_value" )
31+ Tags . of ( this . collection ) . add ( "version" , "static_value" )
32+
2733 // Grant access to the Bedrock execution role
2834 this . collection . grantDataAccess ( props . bedrockExecutionRole )
2935
0 commit comments