|
2 | 2 |
|
3 | 3 | OpenStreetMap C++ tools available as an AWS Lambda Layer! |
4 | 4 |
|
5 | | -More details coming soon. |
| 5 | +Run [Open Source Routing Machine](https://github.com/Project-OSRM/osrm-backend), |
| 6 | +[Osmium](https://github.com/osmcode/osmium-tool), and [Tilemaker](https://github.com/systemed/tilemaker) in AWS Lambda |
| 7 | +with precompiled C++ binaries ready to run on Amazon Linux 2023 (used by most Lambda runtimes). |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +1. Open the [Releases](https://github.com/hnryjms/aws-lambda-layer-osmtools/releases) page and find the latest release. |
| 12 | +2. Copy the corresponding `Layer ARN` for your AWS Region. |
| 13 | +3. In `AWS Console > Lambda > (function) > Code > Layers`, paste this `Layer ARN`. |
| 14 | +4. Save your function :) |
| 15 | + |
| 16 | +You can confirm your app is ready with an example handler like: |
| 17 | + |
| 18 | +### NodeJS: |
| 19 | + |
| 20 | +Ensure `@project-osrm/osrm` is marked as [`external`](https://esbuild.github.io/api/#external) in your bundling tools. |
| 21 | + |
| 22 | +```js |
| 23 | +import OSRM from "@project-osrm/osrm"; |
| 24 | +import ChildProcess from "node:child_process"; |
| 25 | + |
| 26 | +export const handler = async (event) => { |
| 27 | + console.log(OSRM.version); |
| 28 | + ChildProcess.execSync("osmium --version", { stdio: "inherit" }); |
| 29 | + ChildProcess.execSync("osrm-customize --version", { stdio: "inherit" }); |
| 30 | + ChildProcess.execSync("tilemaker --help", { stdio: "inherit" }); |
| 31 | + |
| 32 | + |
| 33 | + const response = { |
| 34 | + statusCode: 200, |
| 35 | + body: JSON.stringify('Hello from Lambda!'), |
| 36 | + }; |
| 37 | + return response; |
| 38 | +}; |
| 39 | +``` |
| 40 | + |
| 41 | +## To Do |
| 42 | + |
| 43 | +- [ ] Split OSRM / Osmium / Tilemaker into individual, combinable layers |
| 44 | +- [ ] Add other runtime support (mainly CLI-only option) |
| 45 | + |
| 46 | +## Support |
| 47 | + |
| 48 | +This project is a part of my larger work on [Skyway.run](https://skyway.run), an indoor navigation app. If you find |
| 49 | +`aws-lambda-layer-osmtools` useful on your project, let me know and I can list you here. |
| 50 | + |
| 51 | +Contributors or sponsors very welcome :) |
0 commit comments