Reputation: 3657
I have a AWS Lambda written in Spring Boot. The Spring Boot code makes use of a Process
to execute a npm
command.
This is perfectly fine when running on a server as I can globally install npm packages.
What's the best way to get this working in a lambda?
I toyed around with https://github.com/awslabs/aws-lambda-container-image-converter attempting to create a custom runtime environment which has both Java and the npm package I need. However I wasn't able to get very far due to lack of understanding. I'm even sure if this is the right tool to be using.
So, how can I run both a Java application and execute a npm command in a single lambda?
Upvotes: 2
Views: 985
Reputation: 8830
I believe there are only two options:
Use a AWS Layers with npm binary. As you mentioned you can use a custom runtime or add a new layer to your existing lambda function.
Invoke another lambda function with nodejs runtime synchronously and capture the response. Check java SDK method for Invoke endpoint
Depending on your particular problem, there also a 3rd option to convert your nodejs library into a executable binary using nexe or a similar library
Upvotes: 2