Skip to content

Commit e61f9f0

Browse files
authored
feat(constructs): bring your own lambda (#284)
* chore(qa): add new prop to provide custom lambda function * chore(rag): provide custom lambda props for rag construct * chore(rag): provide custom lambda props for summarization construct * chore(lambda layer): move generated props to a dedicated folder * chore(eslint): fix linting * chore(test): add tests and rename props for more clarity * chore(doc): update documentation to reflect changes
1 parent ef890d6 commit e61f9f0

34 files changed

+1544
-158
lines changed

.eslintrc.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitattributes

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,24 @@ project.eslint?.addRules({
167167

168168
project.eslint?.addIgnorePattern('LangchainProps.ts');
169169
project.eslint?.addIgnorePattern('AdapterProps.ts');
170+
project.eslint?.addIgnorePattern('DockerLambdaCustomProps.ts');
170171

171172
// Shared interfaces extending pre-existing CDK interfaces
172-
new ProjenStruct(project, { name: 'LangchainProps', filePath: 'src/patterns/gen-ai/aws-langchain-common-layer/LangchainProps.ts' })
173+
new ProjenStruct(project, { name: 'LangchainProps', filePath: 'src/common/props/LangchainProps.ts' })
173174
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.LayerVersionProps'))
174175
.withoutDeprecated()
175176
.omit('code', 'compatibleRuntimes', 'compatibleArchitectures');
176177

177-
new ProjenStruct(project, { name: 'AdapterProps', filePath: 'src/patterns/gen-ai/aws-langchain-common-layer/AdapterProps.ts' })
178+
new ProjenStruct(project, { name: 'AdapterProps', filePath: 'src/common/props/AdapterProps.ts' })
178179
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.LayerVersionProps'))
179180
.withoutDeprecated()
180181
.omit('code');
181182

183+
new ProjenStruct(project, { name: 'DockerLambdaCustomProps', filePath: 'src/common/props/DockerLambdaCustomProps.ts' })
184+
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.DockerImageFunctionProps'))
185+
.withoutDeprecated()
186+
.omit('tracing', 'functionName', 'description', 'role', 'vpc', 'vpcSubnets', 'securityGroups', 'role', 'layers', 'allowPublicSubnet', 'allowAllOutbound');
187+
182188
const packageJson = project.tryFindObjectFile('package.json');
183189
packageJson?.patch(JsonPatch.add('/scripts/prepare', 'husky install')); // yarn 1
184190
packageJson?.patch(JsonPatch.add('/scripts/postinstall', 'husky install')); // yarn 2

apidocs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- [ContainerImageConfig](interfaces/ContainerImageConfig.md)
3434
- [ContentGenerationAppSyncLambdaProps](interfaces/ContentGenerationAppSyncLambdaProps.md)
3535
- [CustomSageMakerEndpointProps](interfaces/CustomSageMakerEndpointProps.md)
36+
- [DockerLambdaCustomProps](interfaces/DockerLambdaCustomProps.md)
3637
- [HuggingFaceSageMakerEndpointProps](interfaces/HuggingFaceSageMakerEndpointProps.md)
3738
- [IInstanceAliase](interfaces/IInstanceAliase.md)
3839
- [IInstanceValiant](interfaces/IInstanceValiant.md)

apidocs/classes/ContentGenerationAppSyncLambda.md

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The ContentGenerationAppSyncLambda class.
2020

2121
### Properties
2222

23+
- [cgLambdaFunction](ContentGenerationAppSyncLambda.md#cglambdafunction)
2324
- [generatedImageBus](ContentGenerationAppSyncLambda.md#generatedimagebus)
2425
- [graphqlApi](ContentGenerationAppSyncLambda.md#graphqlapi)
2526
- [node](ContentGenerationAppSyncLambda.md#node)
@@ -69,6 +70,14 @@ Construct.constructor
6970

7071
## Properties
7172

73+
### cgLambdaFunction
74+
75+
`Readonly` **cgLambdaFunction**: `DockerImageFunction`
76+
77+
Returns an instance of appsync.IGraphqlApi created by the construct
78+
79+
___
80+
7281
### generatedImageBus
7382

7483
`Readonly` **generatedImageBus**: `IEventBus`

apidocs/classes/QaAppsyncOpensearch.md

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The QaAppsyncOpensearch class.
2323
- [graphqlApi](QaAppsyncOpensearch.md#graphqlapi)
2424
- [node](QaAppsyncOpensearch.md#node)
2525
- [qaBus](QaAppsyncOpensearch.md#qabus)
26+
- [qaLambdaFunction](QaAppsyncOpensearch.md#qalambdafunction)
2627
- [s3InputAssetsBucket](QaAppsyncOpensearch.md#s3inputassetsbucket)
2728
- [s3InputAssetsBucketInterface](QaAppsyncOpensearch.md#s3inputassetsbucketinterface)
2829
- [securityGroup](QaAppsyncOpensearch.md#securitygroup)
@@ -97,6 +98,14 @@ Returns the instance of events.IEventBus used by the construct
9798

9899
___
99100

101+
### qaLambdaFunction
102+
103+
`Readonly` **qaLambdaFunction**: `DockerImageFunction`
104+
105+
Returns an instance of appsync.IGraphqlApi created by the construct
106+
107+
___
108+
100109
### s3InputAssetsBucket
101110

102111
`Optional` `Readonly` **s3InputAssetsBucket**: `Bucket`

apidocs/classes/RagAppsyncStepfnOpensearch.md

+27
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ The RagAppsyncStepfnOpensearch class.
2020

2121
### Properties
2222

23+
- [embeddingsLambdaFunction](RagAppsyncStepfnOpensearch.md#embeddingslambdafunction)
24+
- [fileTransformerLambdaFunction](RagAppsyncStepfnOpensearch.md#filetransformerlambdafunction)
2325
- [graphqlApi](RagAppsyncStepfnOpensearch.md#graphqlapi)
2426
- [ingestionBus](RagAppsyncStepfnOpensearch.md#ingestionbus)
27+
- [inputValidationLambdaFunction](RagAppsyncStepfnOpensearch.md#inputvalidationlambdafunction)
2528
- [node](RagAppsyncStepfnOpensearch.md#node)
2629
- [s3InputAssetsBucket](RagAppsyncStepfnOpensearch.md#s3inputassetsbucket)
2730
- [s3InputAssetsBucketInterface](RagAppsyncStepfnOpensearch.md#s3inputassetsbucketinterface)
@@ -72,6 +75,22 @@ Construct.constructor
7275

7376
## Properties
7477

78+
### embeddingsLambdaFunction
79+
80+
`Readonly` **embeddingsLambdaFunction**: `DockerImageFunction`
81+
82+
Returns an instance of lambda.DockerImageFunction used for the embeddings job created by the construct
83+
84+
___
85+
86+
### fileTransformerLambdaFunction
87+
88+
`Readonly` **fileTransformerLambdaFunction**: `DockerImageFunction`
89+
90+
Returns an instance of lambda.DockerImageFunction used for the file transformer job created by the construct
91+
92+
___
93+
7594
### graphqlApi
7695

7796
`Readonly` **graphqlApi**: `IGraphqlApi`
@@ -88,6 +107,14 @@ Returns the instance of events.IEventBus used by the construct
88107

89108
___
90109

110+
### inputValidationLambdaFunction
111+
112+
`Readonly` **inputValidationLambdaFunction**: `DockerImageFunction`
113+
114+
Returns an instance of lambda.DockerImageFunction used for the input validation job created by the construct
115+
116+
___
117+
91118
### node
92119

93120
`Readonly` **node**: `Node`

apidocs/classes/SummarizationAppsyncStepfn.md

+27
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616

1717
### Properties
1818

19+
- [documentReaderLambdaFunction](SummarizationAppsyncStepfn.md#documentreaderlambdafunction)
1920
- [eventBridgeBus](SummarizationAppsyncStepfn.md#eventbridgebus)
2021
- [graphqlApi](SummarizationAppsyncStepfn.md#graphqlapi)
2122
- [inputAssetBucket](SummarizationAppsyncStepfn.md#inputassetbucket)
23+
- [inputValidationLambdaFunction](SummarizationAppsyncStepfn.md#inputvalidationlambdafunction)
2224
- [node](SummarizationAppsyncStepfn.md#node)
2325
- [processedAssetBucket](SummarizationAppsyncStepfn.md#processedassetbucket)
2426
- [redisCluster](SummarizationAppsyncStepfn.md#rediscluster)
2527
- [securityGroup](SummarizationAppsyncStepfn.md#securitygroup)
2628
- [stateMachine](SummarizationAppsyncStepfn.md#statemachine)
29+
- [summaryGeneratorLambdaFunction](SummarizationAppsyncStepfn.md#summarygeneratorlambdafunction)
2730
- [vpc](SummarizationAppsyncStepfn.md#vpc)
2831

2932
### Methods
@@ -67,6 +70,14 @@ Construct.constructor
6770

6871
## Properties
6972

73+
### documentReaderLambdaFunction
74+
75+
`Readonly` **documentReaderLambdaFunction**: `DockerImageFunction`
76+
77+
Returns an instance of lambda.DockerImageFunction used for the document reading job created by the construct
78+
79+
___
80+
7081
### eventBridgeBus
7182

7283
`Readonly` **eventBridgeBus**: `IEventBus`
@@ -91,6 +102,14 @@ Returns the instance of s3.IBucket used by the construct
91102

92103
___
93104

105+
### inputValidationLambdaFunction
106+
107+
`Readonly` **inputValidationLambdaFunction**: `DockerImageFunction`
108+
109+
Returns an instance of lambda.DockerImageFunction used for the input validation job created by the construct
110+
111+
___
112+
94113
### node
95114

96115
`Readonly` **node**: `Node`
@@ -141,6 +160,14 @@ Step function
141160

142161
___
143162

163+
### summaryGeneratorLambdaFunction
164+
165+
`Readonly` **summaryGeneratorLambdaFunction**: `DockerImageFunction`
166+
167+
Returns an instance of lambda.DockerImageFunction used for the summary generation job created by the construct
168+
169+
___
170+
144171
### vpc
145172

146173
`Readonly` **vpc**: `IVpc`

apidocs/interfaces/ContentGenerationAppSyncLambdaProps.md

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The properties for the ContentGenerationAppSyncLambdaProps class.
99
### Properties
1010

1111
- [cognitoUserPool](ContentGenerationAppSyncLambdaProps.md#cognitouserpool)
12+
- [customDockerLambdaProps](ContentGenerationAppSyncLambdaProps.md#customdockerlambdaprops)
1213
- [enableOperationalMetric](ContentGenerationAppSyncLambdaProps.md#enableoperationalmetric)
1314
- [existingBusInterface](ContentGenerationAppSyncLambdaProps.md#existingbusinterface)
1415
- [existingGeneratedAssetsBucketObj](ContentGenerationAppSyncLambdaProps.md#existinggeneratedassetsbucketobj)
@@ -37,6 +38,15 @@ Cognito user pool used for authentication.
3738

3839
___
3940

41+
### customDockerLambdaProps
42+
43+
`Optional` `Readonly` **customDockerLambdaProps**: [`DockerLambdaCustomProps`](DockerLambdaCustomProps.md)
44+
45+
Optional. Allows to provide custom lambda code
46+
and settings instead of the existing
47+
48+
___
49+
4050
### enableOperationalMetric
4151

4252
`Optional` `Readonly` **enableOperationalMetric**: `boolean`

0 commit comments

Comments
 (0)