@@ -31,9 +31,10 @@ import * as eventBridge from '../../../common/helpers/eventbridge-helper';
31
31
import { buildDockerLambdaFunction } from '../../../common/helpers/lambda-builder-helper' ;
32
32
import * as redisHelper from '../../../common/helpers/redis-helper' ;
33
33
import * as s3BucketHelper from '../../../common/helpers/s3-bucket-helper' ;
34
- import { generatePhysicalName , version , lambdaMemorySizeLimiter } from '../../../common/helpers/utils' ;
34
+ import { generatePhysicalName , lambdaMemorySizeLimiter } from '../../../common/helpers/utils' ;
35
35
import * as vpcHelper from '../../../common/helpers/vpc-helper' ;
36
36
import { DockerLambdaCustomProps } from '../../../common/props/DockerLambdaCustomProps' ;
37
+ import { BaseClass , BaseClassProps } from '../../../common/base-class/base-class' ;
37
38
38
39
export interface SummarizationAppsyncStepfnProps {
39
40
/**
@@ -205,7 +206,7 @@ export interface SummarizationAppsyncStepfnProps {
205
206
206
207
}
207
208
208
- export class SummarizationAppsyncStepfn extends Construct {
209
+ export class SummarizationAppsyncStepfn extends BaseClass {
209
210
/**
210
211
* Returns an instance of events.IEventBus created by the construct
211
212
*/
@@ -264,10 +265,7 @@ export class SummarizationAppsyncStepfn extends Construct {
264
265
constructor ( scope : Construct , id : string , props : SummarizationAppsyncStepfnProps ) {
265
266
super ( scope , id ) ;
266
267
267
- let stage = '-dev' ;
268
- if ( props ?. stage ) {
269
- stage = props . stage ;
270
- }
268
+
271
269
272
270
// observability
273
271
let lambda_tracing = lambda . Tracing . ACTIVE ;
@@ -319,7 +317,7 @@ export class SummarizationAppsyncStepfn extends Construct {
319
317
320
318
// bucket for storing server access logging
321
319
const serverAccessLogBucket = new s3 . Bucket ( this ,
322
- 'serverAccessLogBucket' + stage ,
320
+ 'serverAccessLogBucket' + this . stage ,
323
321
{
324
322
blockPublicAccess : s3 . BlockPublicAccess . BLOCK_ALL ,
325
323
encryption : s3 . BucketEncryption . S3_MANAGED ,
@@ -341,10 +339,10 @@ export class SummarizationAppsyncStepfn extends Construct {
341
339
this . inputAssetBucket = props . existingInputAssetsBucketObj ;
342
340
} else if ( props ?. bucketInputsAssetsProps ) {
343
341
this . inputAssetBucket = new s3 . Bucket ( this ,
344
- 'inputAssetsSummaryBucket' + stage , props . bucketInputsAssetsProps ) ;
342
+ 'inputAssetsSummaryBucket' + this . stage , props . bucketInputsAssetsProps ) ;
345
343
} else {
346
- const bucketName = 'input-assets-summary-bucket' + stage + '-' + Aws . ACCOUNT_ID ;
347
- this . inputAssetBucket = new s3 . Bucket ( this , 'inputAssetsSummaryBucket' + stage ,
344
+ const bucketName = 'input-assets-summary-bucket' + this . stage + '-' + Aws . ACCOUNT_ID ;
345
+ this . inputAssetBucket = new s3 . Bucket ( this , 'inputAssetsSummaryBucket' + this . stage ,
348
346
{
349
347
blockPublicAccess : s3 . BlockPublicAccess . BLOCK_ALL ,
350
348
encryption : s3 . BucketEncryption . S3_MANAGED ,
@@ -368,11 +366,11 @@ export class SummarizationAppsyncStepfn extends Construct {
368
366
this . processedAssetBucket = props . existingProcessedAssetsBucketObj ;
369
367
} else if ( props ?. bucketProcessedAssetsProps ) {
370
368
this . processedAssetBucket = new s3 . Bucket ( this ,
371
- 'processedAssetsSummaryBucket' + stage , props . bucketProcessedAssetsProps ) ;
369
+ 'processedAssetsSummaryBucket' + this . stage , props . bucketProcessedAssetsProps ) ;
372
370
} else {
373
- const bucketName = 'processed-assets-summary-bucket' + stage + '-' + Aws . ACCOUNT_ID ;
371
+ const bucketName = 'processed-assets-summary-bucket' + this . stage + '-' + Aws . ACCOUNT_ID ;
374
372
375
- this . processedAssetBucket = new s3 . Bucket ( this , 'processedAssetsSummaryBucket' + stage ,
373
+ this . processedAssetBucket = new s3 . Bucket ( this , 'processedAssetsSummaryBucket' + this . stage ,
376
374
{
377
375
blockPublicAccess : s3 . BlockPublicAccess . BLOCK_ALL ,
378
376
encryption : s3 . BucketEncryption . S3_MANAGED ,
@@ -437,9 +435,9 @@ export class SummarizationAppsyncStepfn extends Construct {
437
435
const apiName = props . summaryApiName || 'summaryApi' ;
438
436
439
437
// graphql api for summary. client invoke this api with given schema and cognito user pool auth.
440
- const summarizationGraphqlApi = new appsync . GraphqlApi ( this , 'summarizationGraphqlApi' + stage ,
438
+ const summarizationGraphqlApi = new appsync . GraphqlApi ( this , 'summarizationGraphqlApi' + this . stage ,
441
439
{
442
- name : apiName + stage ,
440
+ name : apiName + this . stage ,
443
441
logConfig : api_log_config ,
444
442
definition : appsync . Definition . fromFile (
445
443
path . join ( __dirname , '../../../../resources/gen-ai/aws-summarization-appsync-stepfn/schema.graphql' ) ,
@@ -528,7 +526,7 @@ export class SummarizationAppsyncStepfn extends Construct {
528
526
529
527
const construct_input_validation_lambda_props = {
530
528
code : lambda . DockerImageCode . fromImageAsset ( path . join ( __dirname , '../../../../lambda/aws-summarization-appsync-stepfn/input_validator' ) ) ,
531
- functionName : 'summary_input_validator' + stage ,
529
+ functionName : 'summary_input_validator' + this . stage ,
532
530
description : 'Lambda function to validate input for summary api' ,
533
531
vpc : this . vpc ,
534
532
tracing : lambda_tracing ,
@@ -544,7 +542,7 @@ export class SummarizationAppsyncStepfn extends Construct {
544
542
545
543
// Lambda function used to validate inputs in the step function
546
544
const inputValidatorLambda = buildDockerLambdaFunction ( this ,
547
- 'inputValidatorLambda' + stage ,
545
+ 'inputValidatorLambda' + this . stage ,
548
546
construct_input_validation_lambda_props ,
549
547
props . customInputValidationDockerLambdaProps ,
550
548
) ;
@@ -618,7 +616,7 @@ export class SummarizationAppsyncStepfn extends Construct {
618
616
619
617
const construct_document_reader_lambda_props = {
620
618
code : lambda . DockerImageCode . fromImageAsset ( path . join ( __dirname , '../../../../lambda/aws-summarization-appsync-stepfn/document_reader' ) ) ,
621
- functionName : 'summary_document_reader' + stage ,
619
+ functionName : 'summary_document_reader' + this . stage ,
622
620
description : 'Lambda function to read the input transformed document' ,
623
621
vpc : this . vpc ,
624
622
vpcSubnets : { subnetType : ec2 . SubnetType . PRIVATE_WITH_EGRESS } ,
@@ -640,7 +638,7 @@ export class SummarizationAppsyncStepfn extends Construct {
640
638
641
639
// Lambda function used to read documents in the step function
642
640
const documentReaderLambda = buildDockerLambdaFunction ( this ,
643
- 'documentReaderLambda' + stage ,
641
+ 'documentReaderLambda' + this . stage ,
644
642
construct_document_reader_lambda_props ,
645
643
props . customDocumentReaderDockerLambdaProps ,
646
644
) ;
@@ -719,7 +717,7 @@ export class SummarizationAppsyncStepfn extends Construct {
719
717
) ;
720
718
721
719
const construct_generate_summary_lambda_props = {
722
- functionName : 'summary_generator' + stage ,
720
+ functionName : 'summary_generator' + this . stage ,
723
721
description : 'Lambda function to generate the summary' ,
724
722
code : lambda . DockerImageCode . fromImageAsset ( path . join ( __dirname , '../../../../lambda/aws-summarization-appsync-stepfn/summary_generator' ) ) ,
725
723
vpc : this . vpc ,
@@ -740,7 +738,7 @@ export class SummarizationAppsyncStepfn extends Construct {
740
738
741
739
// Lambda function used to generate the summary in the step function
742
740
const generateSummarylambda = buildDockerLambdaFunction ( this ,
743
- 'generateSummarylambda' + stage ,
741
+ 'generateSummarylambda' + this . stage ,
744
742
construct_generate_summary_lambda_props ,
745
743
props . customSummaryGeneratorDockerLambdaProps ,
746
744
) ;
@@ -750,33 +748,44 @@ export class SummarizationAppsyncStepfn extends Construct {
750
748
this . inputAssetBucket ?. grantRead ( documentReaderLambda ) ;
751
749
this . processedAssetBucket ?. grantReadWrite ( documentReaderLambda ) ;
752
750
751
+ const baseProps : BaseClassProps = {
752
+ stage : props . stage ,
753
+ enableOperationalMetric : props . enableOperationalMetric ,
754
+ lambdaFunctions : [ documentReaderLambda , generateSummarylambda , inputValidatorLambda ] ,
755
+ constructorName : this . constructor . name ,
756
+ constructId : id
757
+ }
758
+ this . updateConstructTrackingCode ( baseProps , scope )
753
759
754
- const enableOperationalMetric =
755
- props . enableOperationalMetric !== undefined && props . enableOperationalMetric !== null ? props . enableOperationalMetric : true ;
760
+ // const enableOperationalMetric =
761
+ // props.enableOperationalMetric !== undefined && props.enableOperationalMetric !== null ? props.enableOperationalMetric : true;
756
762
757
- if ( enableOperationalMetric ) {
758
- const solutionId = `genai_cdk_${ version } /${ this . constructor . name } /${ id } ` ;
759
- documentReaderLambda . addEnvironment (
760
- 'AWS_SDK_UA_APP_ID' , solutionId ,
761
- ) ;
762
- generateSummarylambda . addEnvironment (
763
- 'AWS_SDK_UA_APP_ID' , solutionId ,
764
- ) ;
765
- inputValidatorLambda . addEnvironment (
766
- 'AWS_SDK_UA_APP_ID' , solutionId ,
767
- ) ;
768
- } ;
763
+ // if (enableOperationalMetric) {
764
+ // const solutionId = `genai_cdk_${version}/${this.constructor.name}/${id}`;
765
+ // documentReaderLambda.addEnvironment(
766
+ // 'AWS_SDK_UA_APP_ID', solutionId,
767
+ // );
768
+ // generateSummarylambda.addEnvironment(
769
+ // 'AWS_SDK_UA_APP_ID', solutionId,
770
+ // );
771
+ // inputValidatorLambda.addEnvironment(
772
+ // 'AWS_SDK_UA_APP_ID', solutionId,
773
+ // );
774
+ // // ADD unique key in CFN stack
775
+ // Stack.of(scope).templateOptions.description =solutionId
776
+
777
+ // };
769
778
770
779
771
780
// create datasource at appsync
772
781
const SummaryStatusDataSource = new appsync . NoneDataSource
773
- ( this , 'noneDataSource' + stage , {
782
+ ( this , 'noneDataSource' + this . stage , {
774
783
api : summarizationGraphqlApi ,
775
784
name : 'SummaryStatusDataSource' ,
776
785
} ) ;
777
786
778
787
SummaryStatusDataSource . createResolver
779
- ( 'summaryResponseresolver' + stage , {
788
+ ( 'summaryResponseresolver' + this . stage , {
780
789
typeName : 'Mutation' ,
781
790
fieldName : 'updateSummaryJobStatus' ,
782
791
requestMappingTemplate : appsync . MappingTemplate . fromString (
@@ -805,7 +814,7 @@ export class SummarizationAppsyncStepfn extends Construct {
805
814
} ) ;
806
815
807
816
const dlq : sqs . Queue = new sqs . Queue ( this , 'dlq' , {
808
- queueName : 'summarydlq' + stage ,
817
+ queueName : 'summarydlq' + this . stage ,
809
818
retentionPeriod : Duration . days ( 7 ) ,
810
819
enforceSSL : true ,
811
820
} ) ;
@@ -939,3 +948,4 @@ export class SummarizationAppsyncStepfn extends Construct {
939
948
940
949
}
941
950
}
951
+
0 commit comments