@gradientedge/cdk-utils 7.9.1 → 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,4 +66,19 @@ export declare class LambdaManager {
|
|
|
66
66
|
* @param {string?} mountPath
|
|
67
67
|
*/
|
|
68
68
|
createEdgeFunction(id: string, scope: common.CommonConstruct, props: types.LambdaEdgeProps, layers: lambda.ILayerVersion[], code: lambda.AssetCode, environment?: any, vpc?: ec2.IVpc, securityGroups?: ec2.ISecurityGroup[], accessPoint?: efs.IAccessPoint, mountPath?: string): cdk.aws_cloudfront.experimental.EdgeFunction;
|
|
69
|
+
/**
|
|
70
|
+
* @summary Method to create a lambda function (nodejs) with docker image
|
|
71
|
+
* @param {string} id scoped id of the resource
|
|
72
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
73
|
+
* @param {types.LambdaProps} props
|
|
74
|
+
* @param {iam.Role | iam.CfnRole} role
|
|
75
|
+
* @param {lambda.DockerImageCode} code
|
|
76
|
+
* @param {Map<string, string>?} environment
|
|
77
|
+
* @param {ec2.IVpc?} vpc
|
|
78
|
+
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
79
|
+
* @param {efs.IAccessPoint?} accessPoint
|
|
80
|
+
* @param {string?} mountPath
|
|
81
|
+
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
82
|
+
*/
|
|
83
|
+
createLambdaDockerFunction(id: string, scope: common.CommonConstruct, props: types.LambdaProps, role: iam.Role | iam.CfnRole, code: lambda.DockerImageCode, environment?: any, vpc?: ec2.IVpc, securityGroups?: ec2.ISecurityGroup[], accessPoint?: efs.IAccessPoint, mountPath?: string, vpcSubnets?: ec2.SubnetSelection): cdk.aws_lambda.DockerImageFunction;
|
|
69
84
|
}
|
|
@@ -142,5 +142,59 @@ class LambdaManager {
|
|
|
142
142
|
createEdgeFunction(id, scope, props, layers, code, environment, vpc, securityGroups, accessPoint, mountPath) {
|
|
143
143
|
return new cloudfront_manager_1.CloudFrontManager().createEdgeFunction(id, scope, props, layers, code, environment, vpc, securityGroups, accessPoint, mountPath);
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* @summary Method to create a lambda function (nodejs) with docker image
|
|
147
|
+
* @param {string} id scoped id of the resource
|
|
148
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
149
|
+
* @param {types.LambdaProps} props
|
|
150
|
+
* @param {iam.Role | iam.CfnRole} role
|
|
151
|
+
* @param {lambda.DockerImageCode} code
|
|
152
|
+
* @param {Map<string, string>?} environment
|
|
153
|
+
* @param {ec2.IVpc?} vpc
|
|
154
|
+
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
155
|
+
* @param {efs.IAccessPoint?} accessPoint
|
|
156
|
+
* @param {string?} mountPath
|
|
157
|
+
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
158
|
+
*/
|
|
159
|
+
createLambdaDockerFunction(id, scope, props, role, code, environment, vpc, securityGroups, accessPoint, mountPath, vpcSubnets) {
|
|
160
|
+
if (!props)
|
|
161
|
+
throw `Lambda props undefined for ${id}`;
|
|
162
|
+
const functionName = `${props.functionName}-${scope.props.stage}`;
|
|
163
|
+
let deadLetterQueue;
|
|
164
|
+
if (props.deadLetterQueueEnabled && props.dlq) {
|
|
165
|
+
const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
|
|
166
|
+
deadLetterQueue = scope.sqsManager.createDeadLetterQueueForLambda(`${id}-dlq`, scope, props, redriveQueue);
|
|
167
|
+
}
|
|
168
|
+
const lambdaFunction = new lambda.DockerImageFunction(scope, `${id}`, {
|
|
169
|
+
...props,
|
|
170
|
+
...{
|
|
171
|
+
allowPublicSubnet: !!vpc,
|
|
172
|
+
functionName: functionName,
|
|
173
|
+
runtime: LambdaManager.NODEJS_RUNTIME,
|
|
174
|
+
code: code,
|
|
175
|
+
deadLetterQueue: deadLetterQueue,
|
|
176
|
+
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
177
|
+
environment: {
|
|
178
|
+
REGION: scope.props.region,
|
|
179
|
+
LAST_MODIFIED_TS: new Date().toISOString(),
|
|
180
|
+
STAGE: scope.props.stage,
|
|
181
|
+
...environment,
|
|
182
|
+
},
|
|
183
|
+
filesystem: accessPoint
|
|
184
|
+
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
185
|
+
: undefined,
|
|
186
|
+
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
187
|
+
role: role instanceof iam.Role ? role : undefined,
|
|
188
|
+
securityGroups: securityGroups,
|
|
189
|
+
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
|
|
190
|
+
vpc: vpc,
|
|
191
|
+
vpcSubnets: vpcSubnets,
|
|
192
|
+
tracing: props.tracing,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
|
|
196
|
+
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName);
|
|
197
|
+
return lambdaFunction;
|
|
198
|
+
}
|
|
145
199
|
}
|
|
146
200
|
exports.LambdaManager = LambdaManager;
|
package/package.json
CHANGED
|
@@ -166,4 +166,75 @@ export class LambdaManager {
|
|
|
166
166
|
mountPath
|
|
167
167
|
)
|
|
168
168
|
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @summary Method to create a lambda function (nodejs) with docker image
|
|
172
|
+
* @param {string} id scoped id of the resource
|
|
173
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
174
|
+
* @param {types.LambdaProps} props
|
|
175
|
+
* @param {iam.Role | iam.CfnRole} role
|
|
176
|
+
* @param {lambda.DockerImageCode} code
|
|
177
|
+
* @param {Map<string, string>?} environment
|
|
178
|
+
* @param {ec2.IVpc?} vpc
|
|
179
|
+
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
180
|
+
* @param {efs.IAccessPoint?} accessPoint
|
|
181
|
+
* @param {string?} mountPath
|
|
182
|
+
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
183
|
+
*/
|
|
184
|
+
public createLambdaDockerFunction(
|
|
185
|
+
id: string,
|
|
186
|
+
scope: common.CommonConstruct,
|
|
187
|
+
props: types.LambdaProps,
|
|
188
|
+
role: iam.Role | iam.CfnRole,
|
|
189
|
+
code: lambda.DockerImageCode,
|
|
190
|
+
environment?: any,
|
|
191
|
+
vpc?: ec2.IVpc,
|
|
192
|
+
securityGroups?: ec2.ISecurityGroup[],
|
|
193
|
+
accessPoint?: efs.IAccessPoint,
|
|
194
|
+
mountPath?: string,
|
|
195
|
+
vpcSubnets?: ec2.SubnetSelection
|
|
196
|
+
) {
|
|
197
|
+
if (!props) throw `Lambda props undefined for ${id}`
|
|
198
|
+
|
|
199
|
+
const functionName = `${props.functionName}-${scope.props.stage}`
|
|
200
|
+
|
|
201
|
+
let deadLetterQueue
|
|
202
|
+
if (props.deadLetterQueueEnabled && props.dlq) {
|
|
203
|
+
const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props)
|
|
204
|
+
deadLetterQueue = scope.sqsManager.createDeadLetterQueueForLambda(`${id}-dlq`, scope, props, redriveQueue)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const lambdaFunction = new lambda.DockerImageFunction(scope, `${id}`, {
|
|
208
|
+
...props,
|
|
209
|
+
...{
|
|
210
|
+
allowPublicSubnet: !!vpc,
|
|
211
|
+
functionName: functionName,
|
|
212
|
+
runtime: LambdaManager.NODEJS_RUNTIME,
|
|
213
|
+
code: code,
|
|
214
|
+
deadLetterQueue: deadLetterQueue,
|
|
215
|
+
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
216
|
+
environment: {
|
|
217
|
+
REGION: scope.props.region,
|
|
218
|
+
LAST_MODIFIED_TS: new Date().toISOString(),
|
|
219
|
+
STAGE: scope.props.stage,
|
|
220
|
+
...environment,
|
|
221
|
+
},
|
|
222
|
+
filesystem: accessPoint
|
|
223
|
+
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
224
|
+
: undefined,
|
|
225
|
+
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
226
|
+
role: role instanceof iam.Role ? role : undefined,
|
|
227
|
+
securityGroups: securityGroups,
|
|
228
|
+
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
|
|
229
|
+
vpc: vpc,
|
|
230
|
+
vpcSubnets: vpcSubnets,
|
|
231
|
+
tracing: props.tracing,
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
236
|
+
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
237
|
+
|
|
238
|
+
return lambdaFunction
|
|
239
|
+
}
|
|
169
240
|
}
|