@@ -13,7 +13,11 @@ import {
1313 Stack ,
1414} from "aws-cdk-lib" ;
1515import { Construct } from "constructs" ;
16- import { CustomLambdaFunctionProps , DEFAULT_PGSTAC_VERSION } from "../utils" ;
16+ import {
17+ CustomLambdaFunctionProps ,
18+ DEFAULT_PGSTAC_VERSION ,
19+ resolveLambdaCode ,
20+ } from "../utils" ;
1721
1822export class StacIngestor extends Construct {
1923 table : dynamodb . Table ;
@@ -116,14 +120,17 @@ export class StacIngestor extends Construct {
116120 lambdaFunctionOptions ?: CustomLambdaFunctionProps ;
117121 pgstacVersion ?: string ;
118122 } ) : lambda . Function {
123+ const { code : userCode , ...otherLambdaOptions } =
124+ props . lambdaFunctionOptions || { } ;
125+
119126 const handler = new lambda . Function ( this , "api-handler" , {
120127 // defaults
121128 runtime : lambda . Runtime . PYTHON_3_12 ,
122129 handler : "src.handler.handler" ,
123130 memorySize : 2048 ,
124131 logRetention : aws_logs . RetentionDays . ONE_WEEK ,
125132 timeout : Duration . seconds ( 30 ) ,
126- code : lambda . Code . fromDockerBuild ( __dirname , {
133+ code : resolveLambdaCode ( userCode , __dirname , {
127134 file : "runtime/Dockerfile" ,
128135 buildArgs : {
129136 PYTHON_VERSION : "3.12" ,
@@ -136,7 +143,7 @@ export class StacIngestor extends Construct {
136143 environment : { DB_SECRET_ARN : props . dbSecret . secretArn , ...props . env } ,
137144 role : this . handlerRole ,
138145 // overwrites defaults with user-provided configurable properties
139- ...props . lambdaFunctionOptions ,
146+ ...otherLambdaOptions ,
140147 } ) ;
141148
142149 // Allow handler to read DB secret
@@ -167,14 +174,16 @@ export class StacIngestor extends Construct {
167174 lambdaFunctionOptions ?: CustomLambdaFunctionProps ;
168175 pgstacVersion ?: string ;
169176 } ) : lambda . Function {
177+ const { code : userCode , ...otherLambdaOptions } =
178+ props . lambdaFunctionOptions || { } ;
170179 const handler = new lambda . Function ( this , "stac-ingestor" , {
171180 // defaults
172181 runtime : lambda . Runtime . PYTHON_3_12 ,
173182 handler : "src.ingestor.handler" ,
174183 memorySize : 2048 ,
175184 logRetention : aws_logs . RetentionDays . ONE_WEEK ,
176185 timeout : Duration . seconds ( 180 ) ,
177- code : lambda . Code . fromDockerBuild ( __dirname , {
186+ code : resolveLambdaCode ( userCode , __dirname , {
178187 file : "runtime/Dockerfile" ,
179188 buildArgs : {
180189 PYTHON_VERSION : "3.12" ,
@@ -187,7 +196,7 @@ export class StacIngestor extends Construct {
187196 environment : { DB_SECRET_ARN : props . dbSecret . secretArn , ...props . env } ,
188197 role : this . handlerRole ,
189198 // overwrites defaults with user-provided configurable properties
190- ...props . lambdaFunctionOptions ,
199+ ...otherLambdaOptions ,
191200 } ) ;
192201
193202 // Allow handler to read DB secret
0 commit comments