@@ -16,6 +16,7 @@ import { Construct } from "constructs";
1616
1717export class PgStacApiLambda extends Construct {
1818 readonly url : string ;
19+ public stacApiLambdaFunction : PythonFunction ;
1920
2021 constructor ( scope : Construct , id : string , props : PgStacApiLambdaProps ) {
2122 super ( scope , id ) ;
@@ -26,7 +27,7 @@ export class PgStacApiLambda extends Construct {
2627 handler : "handler" ,
2728 } ;
2829
29- const handler = new PythonFunction ( this , "stac-api" , {
30+ this . stacApiLambdaFunction = new PythonFunction ( this , "stac-api" , {
3031 ...apiCode ,
3132 /**
3233 * NOTE: Unable to use Py3.9, due to issues with hashes:
@@ -53,11 +54,11 @@ export class PgStacApiLambda extends Construct {
5354 memorySize : 8192 ,
5455 } ) ;
5556
56- props . dbSecret . grantRead ( handler ) ;
57- handler . connections . allowTo ( props . db , ec2 . Port . tcp ( 5432 ) ) ;
57+ props . dbSecret . grantRead ( this . stacApiLambdaFunction ) ;
58+ this . stacApiLambdaFunction . connections . allowTo ( props . db , ec2 . Port . tcp ( 5432 ) ) ;
5859
5960 const stacApi = new HttpApi ( this , `${ Stack . of ( this ) . stackName } -stac-api` , {
60- defaultIntegration : new HttpLambdaIntegration ( "integration" , handler ) ,
61+ defaultIntegration : new HttpLambdaIntegration ( "integration" , this . stacApiLambdaFunction ) ,
6162 } ) ;
6263
6364 this . url = stacApi . url ! ;
0 commit comments