I am trying to create an L3 construct as a nested stack which will create a lambda function among other things.
We already use NodejsFunction heavily and rely on it's use of esbuild to bundle our functions.
With the construct I need to create a NodejsFunction resource in a nested stack, however I am getting the following error.
Unzipped size must be smaller than 262144000 bytes
If I lift the NodejsFunction up to the parent stack, it works fine.
The size of the functions bundle? 3KB
Layers? None
CDK version? Latest
What I have been able to get work is using the more basic Function construct, though this isn't really suitable for my stack.
// inside nested stack
this.lambda = new lambda.Function(this, 'ConsumerExampleLambda', {
functionName: `consumer-${name}`,
memorySize: 1024,
runtime: Runtime.NODEJS_18_X,
handler: 'handler',
environment: {},
code: lambda.Code.fromInline(`
exports.handler = async (event) => {
console.log('Received event:', JSON.stringify(event, null, 2));
return event;
};
`),
});
For reference here is my NodejsFunction that I am trying to deploy
this.lambda = new NodejsFunction(this, 'ConsumerExampleLambda', {
functionName: `consumer-${name}`,
memorySize: 1024,
runtime: Runtime.NODEJS_18_X,
handler: 'handler',
bundling: {
logLevel: LogLevel.WARNING,
target: 'es2020',
externalModules: [
'@nestjs/microservices',
'@nestjs/microservices/microservices-module',
'@nestjs/websockets/socket-module',
],
},
entry: bundling.entry,
});