rococo
rococo

Reputation: 2657

Run a binary executable from a JAR for AWS Lambda

I need to run wdiff from a JAR file. Locally, I do this by invoking a process that runs either the wdiff binary manually installed on a Linux server or a wdiff.exe located in a convenient nearby folder on Windows.

Now, I need to deploy to AWS Lambda, and can't rely on wdiff (or its dependency, diff) to be installed. So how can I get wdiff to run on Lambda?

I guess there are two possible questions/solutions here:

  1. Is it possible to include a third-party binary on the AWS Lambda container?
  2. Is it possible to bundle an executable binary inside a JAR file and execute it from code?

Upvotes: 1

Views: 1604

Answers (1)

Yann
Yann

Reputation: 2532

Create a Lambda layer with the binary you need. You can get /usr/bin/wdiff from a runtime similar to the AWS Lambda one. In your case almost any linux would be fine. If diff of any other dependencies are not installed, put then into the same layer.

Then you can call the binary inside the jar as a usual external program, for example with ProcessBuilder

Upvotes: 3

Related Questions