44 StackProps ,
55 CfnOutput
66} from "aws-cdk-lib"
7- import { EventType } from "aws-cdk-lib/aws-s3"
8- import { S3EventSource } from "aws-cdk-lib/aws-lambda-event-sources"
97import { nagSuppressions } from "../nagSuppressions"
108import { Apis } from "../resources/Apis"
119import { Functions } from "../resources/Functions"
@@ -15,6 +13,7 @@ import {OpenSearchResources} from "../resources/OpenSearchResources"
1513import { VectorKnowledgeBaseResources } from "../resources/VectorKnowledgeBaseResources"
1614import { IamResources } from "../resources/IamResources"
1715import { VectorIndex } from "../resources/VectorIndex"
16+ import { S3LambdaNotification } from "../constructs/S3LambdaNotification"
1817
1918const VECTOR_INDEX_NAME = "eps-assist-os-index"
2019
@@ -133,12 +132,11 @@ export class EpsAssistMeStack extends Stack {
133132 vectorKB . dataSource . attrDataSourceId
134133 )
135134
136- // Add S3 event source mapping to sync Lambda function
137- functions . functions . syncKnowledgeBase . function . addEventSource (
138- new S3EventSource ( storage . kbDocsBucket . bucket , {
139- events : [ EventType . OBJECT_CREATED ]
140- } )
141- )
135+ // Add S3 notification to trigger sync Lambda function
136+ new S3LambdaNotification ( this , "S3ToLambdaNotification" , {
137+ bucket : storage . kbDocsBucket . bucket ,
138+ lambdaFunction : functions . functions . syncKnowledgeBase . function
139+ } )
142140
143141 // Create Apis and pass the Lambda function
144142 const apis = new Apis ( this , "Apis" , {
0 commit comments