I'm trying to create and upload a lambda using the AWS CDK for Java. The following code is what I use to create the lambda in the Stack. However this throws a java.lang.ClassNotFoundException when trying to run the lambda.
private fun createUserLambda(): Function {
val dirPath = System.getProperty("user.dir")
val lambdaDir = File("$dirPath/src/com/test/lambda")
val props = FunctionProps.builder()
.code(Code.fromAsset(File(lambdaDir, "handler").toString()))
.handler(AddUser::class.java.canonicalName + "::" + AddUser::handleRequest.name)
.runtime(Runtime.JAVA_8)
.build()
return Function(this, "UserCreateLambda", props)
}
I can see that the code exists which I download the zip file from the S3 bucket created which contains the assets. Not entirely sure what's missing here but any help would be greatly appreciated! Thanks