Skip to content

Commit f0f3e82

Browse files
authored
Merge pull request #216 from oconpa/feat/typesnpackages
feat: Layer Types and Additional Packages
2 parents 4b6575d + b913199 commit f0f3e82

File tree

15 files changed

+182
-54
lines changed

15 files changed

+182
-54
lines changed

.eslintrc.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitattributes

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/deps.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13+
import { ProjenStruct, Struct } from '@mrgrain/jsii-struct-builder';
1314
import { JsonPatch, awscdk } from 'projen';
1415
import { NpmAccess } from 'projen/lib/javascript';
1516
import {
@@ -51,6 +52,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
5152
'eslint-plugin-header',
5253
'husky',
5354
'pinst',
55+
'@mrgrain/jsii-struct-builder',
5456
],
5557
deps: ['cdk-nag'],
5658

@@ -157,6 +159,20 @@ project.eslint?.addRules({
157159
'header/header': [2, 'header.js'],
158160
});
159161

162+
project.eslint?.addIgnorePattern('LangchainProps.ts');
163+
project.eslint?.addIgnorePattern('AdapterProps.ts');
164+
165+
// Shared interfaces extending pre-existing CDK interfaces
166+
new ProjenStruct(project, { name: 'LangchainProps', filePath: 'src/patterns/gen-ai/aws-langchain-common-layer/LangchainProps.ts' })
167+
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.LayerVersionProps'))
168+
.withoutDeprecated()
169+
.omit('code', 'compatibleRuntimes', 'compatibleArchitectures');
170+
171+
new ProjenStruct(project, { name: 'AdapterProps', filePath: 'src/patterns/gen-ai/aws-langchain-common-layer/AdapterProps.ts' })
172+
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.LayerVersionProps'))
173+
.withoutDeprecated()
174+
.omit('code');
175+
160176
const packageJson = project.tryFindObjectFile('package.json');
161177
packageJson?.patch(JsonPatch.add('/scripts/prepare', 'husky install')); // yarn 1
162178
packageJson?.patch(JsonPatch.add('/scripts/postinstall', 'husky install')); // yarn 2

package.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/helpers/python-lambda-layer-helper.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import * as cdk from 'aws-cdk-lib';
1515
import * as lambda from 'aws-cdk-lib/aws-lambda';
1616
import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
1717
import { Construct } from 'constructs';
18+
import { LangchainProps } from '../../patterns/gen-ai/aws-langchain-common-layer/LangchainProps';
1819

19-
export interface LayerProps {
20+
export interface LayerProps extends LangchainProps {
2021
runtime: lambda.Runtime;
2122
architecture: lambda.Architecture;
2223
path: string;
23-
description: string;
2424
autoUpgrade?: boolean;
25+
additionalPackages?: string[];
2526
local?: 'python' | 'python3';
2627
}
2728

@@ -31,9 +32,12 @@ export class Layer extends Construct {
3132
constructor(scope: Construct, id: string, props: LayerProps) {
3233
super(scope, id);
3334

34-
const { runtime, architecture, path, description, autoUpgrade, local } = props;
35+
const { runtime, architecture, path, additionalPackages, autoUpgrade, local } = props;
3536

3637
const args = local ? [] : ['-t /asset-output/python'];
38+
if (additionalPackages) {
39+
args.push(...additionalPackages);
40+
}
3741
if (autoUpgrade) {
3842
args.push('--upgrade');
3943
}
@@ -70,8 +74,7 @@ export class Layer extends Construct {
7074
code: lambda.Code.fromBucket(layerAsset.bucket, layerAsset.s3ObjectKey),
7175
compatibleRuntimes: [runtime],
7276
compatibleArchitectures: [architecture],
73-
removalPolicy: cdk.RemovalPolicy.DESTROY,
74-
description: description,
77+
...props,
7578
});
7679

7780
this.layer = layer;

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
export * from './patterns/gen-ai/aws-rag-appsync-stepfn-opensearch';
1414
export * from './patterns/gen-ai/aws-summarization-appsync-stepfn';
1515
export * from './patterns/gen-ai/aws-langchain-common-layer';
16+
export * from './patterns/gen-ai/aws-langchain-common-layer/LangchainProps';
17+
export * from './patterns/gen-ai/aws-langchain-common-layer/AdapterProps';
1618
export * from './patterns/gen-ai/aws-qa-appsync-opensearch';
1719
export * from './patterns/gen-ai/aws-model-deployment-sagemaker';
20+
1821
export { version } from './common/helpers/utils';

0 commit comments

Comments
 (0)