-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
(aws-cdk-lib): (NodejsFunction & NestedStack) #30627
Comments
Hello @khushail , Appreciate the help here. |
@TirushV , thanks for reaching out. Looks like you are deploying with an old version . Could you please try using the latest cdk version 2.147.0 and share updates if it still persists? |
@khushail Tried
It seems that cdk is bundling the whole root folder instead of lambda entry file. That the bug |
Hey @TirushV , I tried to repro the issue as mentioned by you but did not see anything happening as such. Could you please share more details I might be missing in reproduction of the issue ? where should I see the zipped package ? |
Could you share the code snippet you tried? also which Main issue is its not zipping the file. Its trying to zip the whole cdk root folder. |
@TirushV Good afternoon. Somehow, I'm unable to reproduce the issue. Below is the TypeScript CDK code: exports.handler = async function() {
return {
statusCode: 200,
headers: { "Content-Type": "text/plain" },
body: 'Hello, CDK!'
};
}; /lib/NestedStack.ts import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import { Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';
import * as path from 'path';
export class NestStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const lambdaAppDir = path.resolve(__dirname, '../lambda');
const fn = new NodejsFunction(this, `function`, {
functionName: 'test-function',
runtime: Runtime.NODEJS_16_X,
timeout: cdk.Duration.seconds(10),
memorySize: 128,
architecture: Architecture.ARM_64, // Used ARM_64 since running CDK Deploy on Apple M1 MacBook Pro
entry: path.join(lambdaAppDir, 'index.ts'),
});
}
} /bin/issue30627.ts #!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { NestStack } from '../lib/NestStack';
const app = new cdk.App();
interface stackProps {
i: number;
}
export class FirstStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: stackProps) {
super(scope, id);
const { i } = props;
for (let k = 0; k < props.i; k++) {
new NestStack(this, `NestStack${k}`);
}
}
}
new FirstStack(app, 'TestStack', { i: 4 }); Kindly note that in above code:
Running
The error above is different since there is already a function named If the issue still persists at your end, kindly share the minimal code solution (excluding the Thanks, |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Describe the bug
When deploying NestedStack with NodejsFunction construct the entry of lambda function is actually taking wrong file. Its bundling the root folder of CDK and then trying to upload this on Lambda function (nodejs). This issue is open since 2 years (2022). Expecting it to be deployed with right entry point path file with nested stack.
REFER THIS OLD ISSUE - [#23181](https://github.com/aws/aws-cdk/issues/23181)
Expected Behavior
NodejsFunction should be deployed with correct entry file with NESTED STACK instead of bundling cdk root folder. (which is a very large file and fails due to this)
Current Behavior
Resource handler returned message: "Unzipped size must be smaller than 262144000 bytes (Service: Lambda, Status Code: 400, Request ID: 8a550035-ac30-4f04-8e5a-95ecf6e5b809)" (RequestToken: 4ed9ea28-2951-f1d3-232a-51a21ee23e53, HandlerErrorCode: InvalidRequest), Resource handler returned message: "Unzipped size must be smaller than 262144000 bytes
Reproduction Steps
Bin file
Nested stack file
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.101.1 (build 16ddad1)
Framework Version
No response
Node.js Version
v18.13.0
OS
Sonoma 14.5 (Mac M2 Pro)
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: