@@ -82,6 +82,7 @@ export interface ServiceRegistrationProps {
82
82
export class ServiceDeployer extends Construct {
83
83
/** The custom resource provider for handling "deployment" resources. */
84
84
readonly deploymentResourceProvider : cr . Provider ;
85
+ readonly eventHandler : lambda_node . NodejsFunction ;
85
86
86
87
private invocationPolicy ?: iam . Policy ;
87
88
@@ -93,15 +94,23 @@ export class ServiceDeployer extends Construct {
93
94
* VPC and security group settings for Restate environments that require it.
94
95
*/
95
96
props ?: Pick <
96
- lambda . FunctionOptions ,
97
- "functionName" | "logGroup" | "timeout" | "vpc" | "vpcSubnets" | "securityGroups" | "allowPublicSubnet"
97
+ lambda_node . NodejsFunctionProps ,
98
+ | "allowPublicSubnet"
99
+ | "bundling"
100
+ | "code"
101
+ | "entry"
102
+ | "functionName"
103
+ | "logGroup"
104
+ | "securityGroups"
105
+ | "timeout"
106
+ | "vpc"
107
+ | "vpcSubnets"
98
108
> &
99
- Pick < lambda_node . NodejsFunctionProps , "entry" > &
100
109
Pick < logs . LogGroupProps , "removalPolicy" > ,
101
110
) {
102
111
super ( scope , id ) ;
103
112
104
- const eventHandler = new lambda_node . NodejsFunction ( this , "EventHandler" , {
113
+ this . eventHandler = new lambda_node . NodejsFunction ( this , "EventHandler" , {
105
114
functionName : props ?. functionName ,
106
115
logGroup : props ?. logGroup ,
107
116
description : "Restate custom registration handler" ,
@@ -130,13 +139,15 @@ export class ServiceDeployer extends Construct {
130
139
if ( ! props ?. logGroup ) {
131
140
// By default, Lambda Functions have a log group with never-expiring retention policy.
132
141
new logs . LogGroup ( this , "DeploymentLogs" , {
133
- logGroupName : `/aws/lambda/${ eventHandler . functionName } ` ,
142
+ logGroupName : `/aws/lambda/${ this . eventHandler . functionName } ` ,
134
143
retention : logs . RetentionDays . ONE_MONTH ,
135
- removalPolicy : cdk . RemovalPolicy . RETAIN_ON_UPDATE_OR_DELETE ,
144
+ removalPolicy : props ?. removalPolicy ?? cdk . RemovalPolicy . RETAIN_ON_UPDATE_OR_DELETE ,
136
145
} ) ;
137
146
}
138
147
139
- this . deploymentResourceProvider = new cr . Provider ( this , "CustomResourceProvider" , { onEventHandler : eventHandler } ) ;
148
+ this . deploymentResourceProvider = new cr . Provider ( this , "CustomResourceProvider" , {
149
+ onEventHandler : this . eventHandler ,
150
+ } ) ;
140
151
}
141
152
142
153
/**
0 commit comments