@@ -13,7 +13,7 @@ export class OpenSearchCollection extends Construct {
1313 constructor ( scope : Construct , id : string , props : OpenSearchCollectionProps ) {
1414 super ( scope , id )
1515
16- // Encryption policy for collection ( AWS-owned key)
16+ // Encryption policy using AWS-managed keys
1717 const encryptionPolicy = new CfnSecurityPolicy ( this , "EncryptionPolicy" , {
1818 name : `${ props . collectionName } -encryption` ,
1919 type : "encryption" ,
@@ -23,7 +23,7 @@ export class OpenSearchCollection extends Construct {
2323 } )
2424 } )
2525
26- // Network policy for public access (collection & dashboard)
26+ // Network policy allowing public internet access
2727 const networkPolicy = new CfnSecurityPolicy ( this , "NetworkPolicy" , {
2828 name : `${ props . collectionName } -network` ,
2929 type : "network" ,
@@ -36,18 +36,7 @@ export class OpenSearchCollection extends Construct {
3636 } ] )
3737 } )
3838
39- // OpenSearch collection (VECTORSEARCH type)
40- this . collection = new CfnCollection ( this , "Collection" , {
41- name : props . collectionName ,
42- description : "EPS Assist Vector Store" ,
43- type : "VECTORSEARCH"
44- } )
45-
46- // Ensure collection is created after policies
47- this . collection . addDependency ( encryptionPolicy )
48- this . collection . addDependency ( networkPolicy )
49-
50- // Access policy for principals (full access to collection & indexes)
39+ // Data access policy granting full permissions to specified principals
5140 const accessPolicy = new CfnAccessPolicy ( this , "AccessPolicy" , {
5241 name : `${ props . collectionName } -access` ,
5342 type : "data" ,
@@ -60,10 +49,18 @@ export class OpenSearchCollection extends Construct {
6049 } ] )
6150 } )
6251
63- // Ensure access policy applies after collection creation
52+ // Vector search collection for document embeddings
53+ this . collection = new CfnCollection ( this , "Collection" , {
54+ name : props . collectionName ,
55+ description : "EPS Assist Vector Store" ,
56+ type : "VECTORSEARCH"
57+ } )
58+
59+ // Ensure collection waits for all policies
60+ this . collection . addDependency ( encryptionPolicy )
61+ this . collection . addDependency ( networkPolicy )
6462 this . collection . addDependency ( accessPolicy )
6563
66- // Collection endpoint
6764 this . endpoint = `${ this . collection . attrId } .${ this . collection . stack . region } .aoss.amazonaws.com`
6865 }
6966}
0 commit comments