1 Antwort
- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
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/
beantwortet vor einem Jahr
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor einem Jahr
- AWS OFFICIALAktualisiert vor 3 Jahren