1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
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/
respondido há um ano
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 2 anos