aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.33k stars 3.76k forks source link

(aws-lambda-nodejs): Windows bundling issue with chain command #30543

Open smivanhamrah opened 2 weeks ago

smivanhamrah commented 2 weeks ago

Describe the bug

We are not able to bundle the lambdas using aws-cdk. we get Illegal character '"' in input file. error. Windows CMD doesn't not support "&&" as chain command, and instead we should use ";"

// packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts

function chain(commands: string[]): string {
  return commands.filter(c => !!c).join(' && ');
}

we need to change this function to

// packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
function chain(commands: string[]): string {
  const sign = this.osPlatform === 'win32' ? ';' : '&&';
  return commands.filter(c => !!c).join(` ${sign} `);
}

Expected Behavior

yarn cdk deploy .. should be able to bundle the lambdas on windows

Current Behavior

yarn cdk deploy .. raises Illegal character '"' in input file. error on windows.

Reproduction Steps

Try to run following sample on windows

const stack = cdk.Stack()
new lambdaNodeJs.NodejsFunction(stack, 'id', ...)

and then try to bundle the stack

yarn cdk synth

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.133.0

Framework Version

No response

Node.js Version

v22.1.0

OS

windows

Language

TypeScript

Language Version

5.4.3

Other information

No response

ashishdhingra commented 2 weeks ago

Most likely a valid issue.

@smivanhamrah Good afternoon. Thanks for reporting the issue and drafting the PR. Could you please share the minimal reproducible code sample for us to troubleshoot the issue?

Thanks, Ashish