File tree Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -476,29 +476,40 @@ export class CdkFramework implements IFramework {
476476 . then ( ( ) => true )
477477 . catch ( ( ) => false ) ,
478478 ) ;
479-
480- if ( ! codePath ) {
481- throw new Error (
482- `Code file not found for Lambda function ${ lambda . code . path } ` ,
483- ) ;
484- }
485479 }
486480
487- const packageJsonPath = await findPackageJson ( codePath ) ;
488- Logger . verbose ( `[CDK] package.json path: ${ packageJsonPath } ` ) ;
481+ let packageJsonPath : string | undefined ;
482+ if ( codePath ) {
483+ packageJsonPath = await findPackageJson ( codePath ) ;
484+ Logger . verbose ( `[CDK] package.json path: ${ packageJsonPath } ` ) ;
485+ }
489486
490487 return {
491488 cdkPath : lambda . cdkPath ,
492489 stackName : lambda . stackName ,
493490 packageJsonPath,
494- codePath,
491+ codePath : codePath ,
495492 handler,
496493 bundling : lambda . bundling ,
497494 } ;
498495 } ) ,
499496 ) ;
500497
501- return list ;
498+ const filteredList = list . filter ( ( lambda ) => lambda . codePath ) ;
499+ const noCodeList = list . filter ( ( lambda ) => ! lambda . codePath ) ;
500+
501+ if ( noCodeList . length > 0 ) {
502+ Logger . warn (
503+ `[CDK] For the following Lambda functions the code file could not be determined and they will be ignored. Inline code is not supported.\n - ${ noCodeList
504+ . map ( ( l ) => `${ l . cdkPath } ` )
505+ . join ( '\n - ' ) } `,
506+ ) ;
507+ }
508+
509+ return filteredList . map ( ( lambda ) => ( {
510+ ...lambda ,
511+ codePath : lambda . codePath ! ,
512+ } ) ) ;
502513 }
503514
504515 /**
Original file line number Diff line number Diff line change @@ -46,6 +46,24 @@ export class CdkbasicStack extends cdk.Stack {
4646 } ,
4747 ) ;
4848
49+ const functionInlineCode = new lambda . Function ( this , 'TestInlineCode' , {
50+ runtime : lambda . Runtime . NODEJS_22_X ,
51+ handler : 'index.handler' ,
52+ code : lambda . Code . fromInline ( `
53+ exports.handler = async (event) => {
54+ const response = {
55+ statusCode: 200,
56+ body: JSON.stringify({
57+ message: 'Hello from inline Lambda function!',
58+ timestamp: new Date().toISOString(),
59+ event: event
60+ }),
61+ };
62+ };
63+ ` ) ,
64+ logRetention : log . RetentionDays . ONE_DAY ,
65+ } ) ;
66+
4967 new cdk . CfnOutput ( this , 'FunctionNameTestTsCommonJs' , {
5068 value : functionTestTsCommonJs . functionName ,
5169 } ) ;
@@ -57,5 +75,9 @@ export class CdkbasicStack extends cdk.Stack {
5775 new cdk . CfnOutput ( this , 'FunctionNameTestJsCommonJs' , {
5876 value : functionTestJsCommonJs . functionName ,
5977 } ) ;
78+
79+ new cdk . CfnOutput ( this , 'FunctionNameTestInlineCode' , {
80+ value : functionInlineCode . functionName ,
81+ } ) ;
6082 }
6183}
You can’t perform that action at this time.
0 commit comments