Skip to content

Commit b6e3ce5

Browse files
roryhackneybennettsf
authored andcommitted
changes lambdaEntry to use ResourceProvider<FunctionResources>
1 parent 6820493 commit b6e3ce5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/rest-api-construct/src/construct.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ void describe('RestApiConstruct Lambda Handling', () => {
1616
const stack = new Stack(app);
1717
const factory = defineFunction({
1818
name: 'Test Function',
19-
entry: './test-assets/handler.js',
19+
entry: './test-assets/handler.ts',
2020
});
21-
const func = factory.getInstance;
2221

2322
//stubs for the instance props
2423
const constructContainer = new ConstructContainerStub(
@@ -34,14 +33,14 @@ void describe('RestApiConstruct Lambda Handling', () => {
3433
resourceNameValidator,
3534
};
3635

37-
const f = func(getInstanceProps).resources.lambda;
36+
const resource = factory.getInstance(getInstanceProps);
3837

3938
new RestApiConstruct(stack, 'RestApiTest', {
4039
apiName: 'RestApiTest',
4140
apiProps: [
4241
{
4342
path: 'items',
44-
lambdaEntry: f,
43+
lambdaEntry: resource,
4544
methods: [
4645
{
4746
method: 'GET',

packages/rest-api-construct/src/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class RestApiConstruct extends Construct {
2626
for (const method of methods) {
2727
resource.addMethod(
2828
method.method,
29-
new apiGateway.LambdaIntegration(lambdaEntry),
29+
new apiGateway.LambdaIntegration(lambdaEntry.resources.lambda),
3030
);
3131
}
3232
}

packages/rest-api-construct/src/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { IFunction } from 'aws-cdk-lib/aws-lambda';
1+
import {
2+
FunctionResources,
3+
ResourceProvider,
4+
} from '@aws-amplify/backend/types/platform';
25

36
export type RestApiConstructProps = {
47
apiName: string;
@@ -18,7 +21,7 @@ export type MethodsProps = {
1821
export type RestApiPathConfig = {
1922
path: string;
2023
methods: MethodsProps[];
21-
lambdaEntry: IFunction;
24+
lambdaEntry: ResourceProvider<FunctionResources>;
2225
};
2326

2427
export type HttpMethod =

0 commit comments

Comments
 (0)