diff --git a/packages/aws-cdk-lib/handler-framework/lib/cdk-handler.ts b/packages/aws-cdk-lib/handler-framework/lib/cdk-handler.ts index 0af8ab1df99b2..d82edcfe9bde2 100644 --- a/packages/aws-cdk-lib/handler-framework/lib/cdk-handler.ts +++ b/packages/aws-cdk-lib/handler-framework/lib/cdk-handler.ts @@ -27,6 +27,11 @@ export class CdkHandler extends Construct { */ private static readonly DEFAULT_RUNTIME = Runtime.NODEJS_LATEST; + /** + * The local file system directory with the provider's code. + */ + public readonly codeDirectory: string; + /** * The source code of your Lambda function. */ @@ -39,6 +44,7 @@ export class CdkHandler extends Construct { public constructor(scope: Construct, id: string, props: CdkHandlerProps) { super(scope, id); + this.codeDirectory = props.codeDirectory; this.code = Code.fromAsset(props.codeDirectory); this.runtime = RuntimeDeterminer.determineLatestRuntime(CdkHandler.DEFAULT_RUNTIME, props.compatibleRuntimes); } diff --git a/packages/aws-cdk-lib/handler-framework/test/cdk-handler.test.ts b/packages/aws-cdk-lib/handler-framework/test/cdk-handler.test.ts index 873df759b58fe..f3e712056a518 100644 --- a/packages/aws-cdk-lib/handler-framework/test/cdk-handler.test.ts +++ b/packages/aws-cdk-lib/handler-framework/test/cdk-handler.test.ts @@ -9,6 +9,20 @@ describe('cdk handler', () => { codeDirectory = path.join(__dirname, 'test-handler'); }); + test('code directory property is correctly set', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + const handler = new CdkHandler(stack, 'CdkHandler', { + codeDirectory, + compatibleRuntimes: [Runtime.NODEJS_16_X, Runtime.NODEJS_LATEST, Runtime.PYTHON_3_12], + }); + + // THEN + expect(handler.codeDirectory).toEqual(codeDirectory); + }); + test('runtime property is correctly set', () => { // GIVEN const stack = new Stack();