1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
The concept of lambda layers will come into the picture only in AWS environment.
When you're testing locally, you can refer to the local package. However, you need to mention this package as external modules when bundling the lambda so that your lambda function will not bundle that package when deploying the lambda.
You would do something like this
const nodeJsFnProps: NodejsFunctionProps = {
bundling: {
externalModules: [
'aws-sdk', // Use the 'aws-sdk' available in the Lambda runtime
'date-fns',
],
},
runtime: Runtime.NODEJS_16_X,
timeout: Duration.minutes(3),
memorySize: 256,
};
const lambdaWithLayer = new NodejsFunction(this, 'lambdaWithLayer', {
entry: path.join(__dirname, '../src/lambdas', 'lambda.ts'),
...nodeJsFnProps,
functionName: 'lambdaWithLayer',
handler: 'handler',
layers: [logicLayer, utilsLayer],
});
I've written a detailed step-by-step guide on lambda layers here - https://www.cloudtechsimplified.com/aws-lambda-layers/
답변함 일 년 전
관련 콘텐츠
- AWS 공식업데이트됨 3년 전
- AWS 공식업데이트됨 일 년 전