8
8
ResponseType ,
9
9
} from 'aws-cdk-lib/aws-apigateway' ;
10
10
import { UserPool , UserPoolClient } from 'aws-cdk-lib/aws-cognito' ;
11
- import { IFunction , Runtime } from 'aws-cdk-lib/aws-lambda' ;
11
+ import { IFunction } from 'aws-cdk-lib/aws-lambda' ;
12
12
import { Construct } from 'constructs' ;
13
13
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
14
14
import { Table } from 'aws-cdk-lib/aws-dynamodb' ;
@@ -28,6 +28,7 @@ import {
28
28
BEDROCK_TEXT_MODELS ,
29
29
} from '@generative-ai-use-cases/common' ;
30
30
import { allowS3AccessWithSourceIpCondition } from '../utils/s3-access-policy' ;
31
+ import { LAMBDA_RUNTIME_NODEJS } from '../../consts' ;
31
32
32
33
export interface BackendApiProps {
33
34
// Context Params
@@ -153,7 +154,7 @@ export class Api extends Construct {
153
154
154
155
// Lambda
155
156
const predictFunction = new NodejsFunction ( this , 'Predict' , {
156
- runtime : Runtime . NODEJS_LATEST ,
157
+ runtime : LAMBDA_RUNTIME_NODEJS ,
157
158
entry : './lambda/predict.ts' ,
158
159
timeout : Duration . minutes ( 15 ) ,
159
160
environment : {
@@ -175,7 +176,7 @@ export class Api extends Construct {
175
176
} ) ;
176
177
177
178
const predictStreamFunction = new NodejsFunction ( this , 'PredictStream' , {
178
- runtime : Runtime . NODEJS_LATEST ,
179
+ runtime : LAMBDA_RUNTIME_NODEJS ,
179
180
entry : './lambda/predictStream.ts' ,
180
181
timeout : Duration . minutes ( 15 ) ,
181
182
memorySize : 256 ,
@@ -213,7 +214,7 @@ export class Api extends Construct {
213
214
214
215
// Add Flow Lambda Function
215
216
const invokeFlowFunction = new NodejsFunction ( this , 'InvokeFlow' , {
216
- runtime : Runtime . NODEJS_LATEST ,
217
+ runtime : LAMBDA_RUNTIME_NODEJS ,
217
218
entry : './lambda/invokeFlow.ts' ,
218
219
timeout : Duration . minutes ( 15 ) ,
219
220
bundling : {
@@ -229,7 +230,7 @@ export class Api extends Construct {
229
230
invokeFlowFunction . grantInvoke ( idPool . authenticatedRole ) ;
230
231
231
232
const predictTitleFunction = new NodejsFunction ( this , 'PredictTitle' , {
232
- runtime : Runtime . NODEJS_LATEST ,
233
+ runtime : LAMBDA_RUNTIME_NODEJS ,
233
234
entry : './lambda/predictTitle.ts' ,
234
235
timeout : Duration . minutes ( 15 ) ,
235
236
bundling : {
@@ -253,7 +254,7 @@ export class Api extends Construct {
253
254
table . grantWriteData ( predictTitleFunction ) ;
254
255
255
256
const generateImageFunction = new NodejsFunction ( this , 'GenerateImage' , {
256
- runtime : Runtime . NODEJS_LATEST ,
257
+ runtime : LAMBDA_RUNTIME_NODEJS ,
257
258
entry : './lambda/generateImage.ts' ,
258
259
timeout : Duration . minutes ( 15 ) ,
259
260
environment : {
@@ -269,7 +270,7 @@ export class Api extends Construct {
269
270
} ) ;
270
271
271
272
const generateVideoFunction = new NodejsFunction ( this , 'GenerateVideo' , {
272
- runtime : Runtime . NODEJS_LATEST ,
273
+ runtime : LAMBDA_RUNTIME_NODEJS ,
273
274
entry : './lambda/generateVideo.ts' ,
274
275
timeout : Duration . minutes ( 15 ) ,
275
276
environment : {
@@ -303,7 +304,7 @@ export class Api extends Construct {
303
304
table . grantWriteData ( generateVideoFunction ) ;
304
305
305
306
const copyVideoJob = new NodejsFunction ( this , 'CopyVideoJob' , {
306
- runtime : Runtime . NODEJS_LATEST ,
307
+ runtime : LAMBDA_RUNTIME_NODEJS ,
307
308
entry : './lambda/copyVideoJob.ts' ,
308
309
timeout : Duration . minutes ( 15 ) ,
309
310
memorySize : 512 ,
@@ -338,7 +339,7 @@ export class Api extends Construct {
338
339
table . grantWriteData ( copyVideoJob ) ;
339
340
340
341
const listVideoJobs = new NodejsFunction ( this , 'ListVideoJobs' , {
341
- runtime : Runtime . NODEJS_LATEST ,
342
+ runtime : LAMBDA_RUNTIME_NODEJS ,
342
343
entry : './lambda/listVideoJobs.ts' ,
343
344
timeout : Duration . minutes ( 15 ) ,
344
345
environment : {
@@ -360,7 +361,7 @@ export class Api extends Construct {
360
361
copyVideoJob . grantInvoke ( listVideoJobs ) ;
361
362
362
363
const deleteVideoJob = new NodejsFunction ( this , 'DeleteVideoJob' , {
363
- runtime : Runtime . NODEJS_LATEST ,
364
+ runtime : LAMBDA_RUNTIME_NODEJS ,
364
365
entry : './lambda/deleteVideoJob.ts' ,
365
366
timeout : Duration . minutes ( 15 ) ,
366
367
environment : {
@@ -376,7 +377,7 @@ export class Api extends Construct {
376
377
this ,
377
378
'OptimizePromptFunction' ,
378
379
{
379
- runtime : Runtime . NODEJS_LATEST ,
380
+ runtime : LAMBDA_RUNTIME_NODEJS ,
380
381
entry : './lambda/optimizePrompt.ts' ,
381
382
timeout : Duration . minutes ( 15 ) ,
382
383
bundling : {
@@ -390,7 +391,7 @@ export class Api extends Construct {
390
391
optimizePromptFunction . grantInvoke ( idPool . authenticatedRole ) ;
391
392
392
393
const getSignedUrlFunction = new NodejsFunction ( this , 'GetSignedUrl' , {
393
- runtime : Runtime . NODEJS_LATEST ,
394
+ runtime : LAMBDA_RUNTIME_NODEJS ,
394
395
entry : './lambda/getFileUploadSignedUrl.ts' ,
395
396
timeout : Duration . minutes ( 15 ) ,
396
397
environment : {
@@ -414,7 +415,7 @@ export class Api extends Construct {
414
415
this ,
415
416
'GetFileDownloadSignedUrlFunction' ,
416
417
{
417
- runtime : Runtime . NODEJS_LATEST ,
418
+ runtime : LAMBDA_RUNTIME_NODEJS ,
418
419
entry : './lambda/getFileDownloadSignedUrl.ts' ,
419
420
timeout : Duration . minutes ( 15 ) ,
420
421
environment : {
@@ -507,7 +508,7 @@ export class Api extends Construct {
507
508
}
508
509
509
510
const createChatFunction = new NodejsFunction ( this , 'CreateChat' , {
510
- runtime : Runtime . NODEJS_LATEST ,
511
+ runtime : LAMBDA_RUNTIME_NODEJS ,
511
512
entry : './lambda/createChat.ts' ,
512
513
timeout : Duration . minutes ( 15 ) ,
513
514
environment : {
@@ -517,7 +518,7 @@ export class Api extends Construct {
517
518
table . grantWriteData ( createChatFunction ) ;
518
519
519
520
const deleteChatFunction = new NodejsFunction ( this , 'DeleteChat' , {
520
- runtime : Runtime . NODEJS_LATEST ,
521
+ runtime : LAMBDA_RUNTIME_NODEJS ,
521
522
entry : './lambda/deleteChat.ts' ,
522
523
timeout : Duration . minutes ( 15 ) ,
523
524
environment : {
@@ -527,7 +528,7 @@ export class Api extends Construct {
527
528
table . grantReadWriteData ( deleteChatFunction ) ;
528
529
529
530
const createMessagesFunction = new NodejsFunction ( this , 'CreateMessages' , {
530
- runtime : Runtime . NODEJS_LATEST ,
531
+ runtime : LAMBDA_RUNTIME_NODEJS ,
531
532
entry : './lambda/createMessages.ts' ,
532
533
timeout : Duration . minutes ( 15 ) ,
533
534
environment : {
@@ -543,7 +544,7 @@ export class Api extends Construct {
543
544
this ,
544
545
'UpdateChatTitle' ,
545
546
{
546
- runtime : Runtime . NODEJS_LATEST ,
547
+ runtime : LAMBDA_RUNTIME_NODEJS ,
547
548
entry : './lambda/updateTitle.ts' ,
548
549
timeout : Duration . minutes ( 15 ) ,
549
550
environment : {
@@ -554,7 +555,7 @@ export class Api extends Construct {
554
555
table . grantReadWriteData ( updateChatTitleFunction ) ;
555
556
556
557
const listChatsFunction = new NodejsFunction ( this , 'ListChats' , {
557
- runtime : Runtime . NODEJS_LATEST ,
558
+ runtime : LAMBDA_RUNTIME_NODEJS ,
558
559
entry : './lambda/listChats.ts' ,
559
560
timeout : Duration . minutes ( 15 ) ,
560
561
environment : {
@@ -564,7 +565,7 @@ export class Api extends Construct {
564
565
table . grantReadData ( listChatsFunction ) ;
565
566
566
567
const findChatbyIdFunction = new NodejsFunction ( this , 'FindChatbyId' , {
567
- runtime : Runtime . NODEJS_LATEST ,
568
+ runtime : LAMBDA_RUNTIME_NODEJS ,
568
569
entry : './lambda/findChatById.ts' ,
569
570
timeout : Duration . minutes ( 15 ) ,
570
571
environment : {
@@ -574,7 +575,7 @@ export class Api extends Construct {
574
575
table . grantReadData ( findChatbyIdFunction ) ;
575
576
576
577
const listMessagesFunction = new NodejsFunction ( this , 'ListMessages' , {
577
- runtime : Runtime . NODEJS_LATEST ,
578
+ runtime : LAMBDA_RUNTIME_NODEJS ,
578
579
entry : './lambda/listMessages.ts' ,
579
580
timeout : Duration . minutes ( 15 ) ,
580
581
environment : {
@@ -584,7 +585,7 @@ export class Api extends Construct {
584
585
table . grantReadData ( listMessagesFunction ) ;
585
586
586
587
const updateFeedbackFunction = new NodejsFunction ( this , 'UpdateFeedback' , {
587
- runtime : Runtime . NODEJS_LATEST ,
588
+ runtime : LAMBDA_RUNTIME_NODEJS ,
588
589
entry : './lambda/updateFeedback.ts' ,
589
590
timeout : Duration . minutes ( 15 ) ,
590
591
environment : {
@@ -594,13 +595,13 @@ export class Api extends Construct {
594
595
table . grantReadWriteData ( updateFeedbackFunction ) ;
595
596
596
597
const getWebTextFunction = new NodejsFunction ( this , 'GetWebText' , {
597
- runtime : Runtime . NODEJS_LATEST ,
598
+ runtime : LAMBDA_RUNTIME_NODEJS ,
598
599
entry : './lambda/getWebText.ts' ,
599
600
timeout : Duration . minutes ( 15 ) ,
600
601
} ) ;
601
602
602
603
const createShareId = new NodejsFunction ( this , 'CreateShareId' , {
603
- runtime : Runtime . NODEJS_LATEST ,
604
+ runtime : LAMBDA_RUNTIME_NODEJS ,
604
605
entry : './lambda/createShareId.ts' ,
605
606
timeout : Duration . minutes ( 15 ) ,
606
607
environment : {
@@ -610,7 +611,7 @@ export class Api extends Construct {
610
611
table . grantReadWriteData ( createShareId ) ;
611
612
612
613
const getSharedChat = new NodejsFunction ( this , 'GetSharedChat' , {
613
- runtime : Runtime . NODEJS_LATEST ,
614
+ runtime : LAMBDA_RUNTIME_NODEJS ,
614
615
entry : './lambda/getSharedChat.ts' ,
615
616
timeout : Duration . minutes ( 15 ) ,
616
617
environment : {
@@ -620,7 +621,7 @@ export class Api extends Construct {
620
621
table . grantReadData ( getSharedChat ) ;
621
622
622
623
const findShareId = new NodejsFunction ( this , 'FindShareId' , {
623
- runtime : Runtime . NODEJS_LATEST ,
624
+ runtime : LAMBDA_RUNTIME_NODEJS ,
624
625
entry : './lambda/findShareId.ts' ,
625
626
timeout : Duration . minutes ( 15 ) ,
626
627
environment : {
@@ -630,7 +631,7 @@ export class Api extends Construct {
630
631
table . grantReadData ( findShareId ) ;
631
632
632
633
const deleteShareId = new NodejsFunction ( this , 'DeleteShareId' , {
633
- runtime : Runtime . NODEJS_LATEST ,
634
+ runtime : LAMBDA_RUNTIME_NODEJS ,
634
635
entry : './lambda/deleteShareId.ts' ,
635
636
timeout : Duration . minutes ( 15 ) ,
636
637
environment : {
@@ -643,7 +644,7 @@ export class Api extends Construct {
643
644
this ,
644
645
'ListSystemContexts' ,
645
646
{
646
- runtime : Runtime . NODEJS_LATEST ,
647
+ runtime : LAMBDA_RUNTIME_NODEJS ,
647
648
entry : './lambda/listSystemContexts.ts' ,
648
649
timeout : Duration . minutes ( 15 ) ,
649
650
environment : {
@@ -657,7 +658,7 @@ export class Api extends Construct {
657
658
this ,
658
659
'CreateSystemContexts' ,
659
660
{
660
- runtime : Runtime . NODEJS_LATEST ,
661
+ runtime : LAMBDA_RUNTIME_NODEJS ,
661
662
entry : './lambda/createSystemContext.ts' ,
662
663
timeout : Duration . minutes ( 15 ) ,
663
664
environment : {
@@ -671,7 +672,7 @@ export class Api extends Construct {
671
672
this ,
672
673
'UpdateSystemContextTitle' ,
673
674
{
674
- runtime : Runtime . NODEJS_LATEST ,
675
+ runtime : LAMBDA_RUNTIME_NODEJS ,
675
676
entry : './lambda/updateSystemContextTitle.ts' ,
676
677
timeout : Duration . minutes ( 15 ) ,
677
678
environment : {
@@ -685,7 +686,7 @@ export class Api extends Construct {
685
686
this ,
686
687
'DeleteSystemContexts' ,
687
688
{
688
- runtime : Runtime . NODEJS_LATEST ,
689
+ runtime : LAMBDA_RUNTIME_NODEJS ,
689
690
entry : './lambda/deleteSystemContext.ts' ,
690
691
timeout : Duration . minutes ( 15 ) ,
691
692
environment : {
@@ -696,7 +697,7 @@ export class Api extends Construct {
696
697
table . grantReadWriteData ( deleteSystemContextFunction ) ;
697
698
698
699
const deleteFileFunction = new NodejsFunction ( this , 'DeleteFileFunction' , {
699
- runtime : Runtime . NODEJS_LATEST ,
700
+ runtime : LAMBDA_RUNTIME_NODEJS ,
700
701
entry : './lambda/deleteFile.ts' ,
701
702
timeout : Duration . minutes ( 15 ) ,
702
703
environment : {
@@ -707,7 +708,7 @@ export class Api extends Construct {
707
708
708
709
// Lambda function for getting token usage
709
710
const getTokenUsageFunction = new NodejsFunction ( this , 'GetTokenUsage' , {
710
- runtime : Runtime . NODEJS_LATEST ,
711
+ runtime : LAMBDA_RUNTIME_NODEJS ,
711
712
entry : './lambda/getTokenUsage.ts' ,
712
713
environment : {
713
714
TABLE_NAME : table . tableName ,
0 commit comments