11import {
2+ aws_ec2 as ec2 ,
23 aws_lambda as lambda ,
34 aws_sqs as sqs ,
45 aws_sns as sns ,
@@ -11,6 +12,7 @@ import {
1112import { Construct } from "constructs" ;
1213import { Platform } from "aws-cdk-lib/aws-ecr-assets" ;
1314import * as path from "path" ;
15+ import { CustomLambdaFunctionProps } from "../utils" ;
1416
1517/**
1618 * Configuration properties for the StactoolsItemGenerator construct.
@@ -40,6 +42,16 @@ export interface StactoolsItemGeneratorProps {
4042 */
4143 readonly lambdaRuntime ?: lambda . Runtime ;
4244
45+ /**
46+ * VPC into which the lambda should be deployed.
47+ */
48+ readonly vpc ?: ec2 . IVpc ;
49+
50+ /**
51+ * Subnet into which the lambda should be deployed.
52+ */
53+ readonly subnetSelection ?: ec2 . SubnetSelection ;
54+
4355 /**
4456 * The timeout for the item generation lambda in seconds.
4557 *
@@ -105,6 +117,13 @@ export interface StactoolsItemGeneratorProps {
105117 * processing and database insertion.
106118 */
107119 readonly itemLoadTopicArn : string ;
120+
121+ /**
122+ * Can be used to override the default lambda function properties.
123+ *
124+ * @default - defined in the construct.
125+ */
126+ readonly lambdaFunctionOptions ?: CustomLambdaFunctionProps ;
108127}
109128
110129/**
@@ -260,7 +279,11 @@ export class StactoolsItemGenerator extends Construct {
260279 */
261280 public readonly lambdaFunction : lambda . DockerImageFunction ;
262281
263- constructor ( scope : Construct , id : string , props : StactoolsItemGeneratorProps ) {
282+ constructor (
283+ scope : Construct ,
284+ id : string ,
285+ props : StactoolsItemGeneratorProps
286+ ) {
264287 super ( scope , id ) ;
265288
266289 const timeoutSeconds = props . lambdaTimeoutSeconds ?? 120 ;
@@ -301,13 +324,17 @@ export class StactoolsItemGenerator extends Construct {
301324 } ,
302325 } ) ,
303326 memorySize : props . memorySize ?? 1024 ,
327+ vpc : props . vpc ,
328+ vpcSubnets : props . subnetSelection ,
304329 timeout : Duration . seconds ( timeoutSeconds ) ,
305330 logRetention : logs . RetentionDays . ONE_WEEK ,
306331 environment : {
307332 ITEM_LOAD_TOPIC_ARN : props . itemLoadTopicArn ,
308333 LOG_LEVEL : "INFO" ,
309334 ...props . environment ,
310335 } ,
336+ // overwrites defaults with user-provided configurable properties
337+ ...props . lambdaFunctionOptions ,
311338 } ) ;
312339
313340 // Add SQS event source to the lambda
0 commit comments