Skip to content

Commit 08c6121

Browse files
committed
Replace S3EventSource with S3LambdaNotification construct
1 parent 30727a3 commit 08c6121

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
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"
97
import {nagSuppressions} from "../nagSuppressions"
108
import {Apis} from "../resources/Apis"
119
import {Functions} from "../resources/Functions"
@@ -15,6 +13,7 @@ import {OpenSearchResources} from "../resources/OpenSearchResources"
1513
import {VectorKnowledgeBaseResources} from "../resources/VectorKnowledgeBaseResources"
1614
import {IamResources} from "../resources/IamResources"
1715
import {VectorIndex} from "../resources/VectorIndex"
16+
import {S3LambdaNotification} from "../constructs/S3LambdaNotification"
1817

1918
const 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

Comments
 (0)