@@ -175,14 +175,8 @@ export class EpsAssistMeStack extends Stack {
175175 } )
176176
177177 // ==== OpenSearch Vector Store ====
178- const osCollection = new ops . CfnCollection ( this , "OsCollection" , {
179- name : "eps-assist-vector-db" ,
180- description : "EPS Assist Vector Store" ,
181- type : "VECTORSEARCH"
182- } )
183-
184178 // OpenSearch encryption policy (AWS-owned key)
185- new ops . CfnSecurityPolicy ( this , "OsEncryptionPolicy" , {
179+ const osEncryptionPolicy = new ops . CfnSecurityPolicy ( this , "OsEncryptionPolicy" , {
186180 name : "eps-assist-encryption-policy" ,
187181 type : "encryption" ,
188182 policy : JSON . stringify ( {
@@ -191,6 +185,16 @@ export class EpsAssistMeStack extends Stack {
191185 } )
192186 } )
193187
188+ // Create the collection after the encryption policy
189+ const osCollection = new ops . CfnCollection ( this , "OsCollection" , {
190+ name : "eps-assist-vector-db" ,
191+ description : "EPS Assist Vector Store" ,
192+ type : "VECTORSEARCH"
193+ } )
194+
195+ // Add explicit dependency to ensure correct creation order
196+ osCollection . addDependency ( osEncryptionPolicy )
197+
194198 // OpenSearch network policy (allow public access for demo purposes)
195199 new ops . CfnSecurityPolicy ( this , "OsNetworkPolicy" , {
196200 name : "eps-assist-network-policy" ,
0 commit comments