in src/main/java/com/awsblog/queueing/cdk/LambdaStack.java [54:97]
public LambdaStack(final Construct parent, final String id,
Configuration config, final StackProps props, Map<String, IRole> roles, Map<String, IFunction> functions) {
super(parent, id, props);
if (!config.getLambdas().isEmpty()) {
System.out.printf(" >> Lambda function construction ... [%s]%n", id);
int counter = 1;
for (ConfigLambda lambdaInfo : config.getLambdas()) {
System.out.printf(">>>>> Constructing Lambda [%s] ->%n > class: [%s]%n > deployment name: [%s]%n",
lambdaInfo.getLogicalName(), lambdaInfo.getClassName(), lambdaInfo.getLambdaDeploymentName());
String jarName = getJarNameFromLocalPath(lambdaInfo.getLocalJarPath());
System.out.printf(" > Code bucket: [%s], JAR [%s]%n", config.getS3CodeBucket(), jarName);
Code code = new S3Code(Bucket.fromBucketName(this, "S3LambdaCode-" + lambdaInfo.getLogicalName() + counter, config.getS3CodeBucket()),
jarName);
FunctionProps lambdaProps = FunctionProps.builder()
.runtime(getLambdaRuntime(lambdaInfo.getRuntime()))
.functionName(lambdaInfo.getLambdaDeploymentName())
.description(lambdaInfo.getDescription())
//.code(Code.asset(Paths.get(lambdaInfo.getLocalJarPath()).toString()))
.code(code)
.handler(lambdaInfo.getClassName() + "::" + lambdaInfo.getHandler())
.role(roles.get("lambda-role"))
.timeout(Duration.seconds(lambdaInfo.getTimeoutInSeconds()))
.memorySize(lambdaInfo.getMemoryInMegabytes())
.build();
IFunction fun = new Function(this, lambdaInfo.getLambdaDeploymentName(), lambdaProps);
// add to the list of IFunction
functions.put(lambdaInfo.getLambdaDeploymentName(), fun);
System.out.printf("Function [%s] ... ARN: [%s]%n", fun.getFunctionName(), fun.getFunctionArn());
++counter;
}
}
}