Skip to content

Commit

Permalink
code directory property
Browse files Browse the repository at this point in the history
Signed-off-by: Francis <colifran@amazon.com>
  • Loading branch information
colifran committed Dec 7, 2023
1 parent efdef2e commit d7a23d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/aws-cdk-lib/handler-framework/lib/cdk-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions packages/aws-cdk-lib/handler-framework/test/cdk-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d7a23d1

Please sign in to comment.