Skip to content

hnryjms/aws-lambda-layer-osmtools

Repository files navigation

aws-lambda-layer-osmtools

OpenStreetMap C++ tools available as an AWS Lambda Layer!

Run Open Source Routing Machine, Osmium, and Tilemaker in AWS Lambda with precompiled C++ binaries ready to run on Amazon Linux 2023 (used by most Lambda runtimes).

Usage

  1. Open the Releases page and find the latest release.
  2. Copy the corresponding Layer ARN for your AWS Region.
  3. In AWS Console > Lambda > (function) > Code > Layers, paste this Layer ARN.
  4. Save your function :)

You can confirm your app is ready with an example handler like:

NodeJS:

Ensure @project-osrm/osrm is marked as external in your bundling tools.

import OSRM from "@project-osrm/osrm";
import ChildProcess from "node:child_process";

export const handler = async (event) => {
  console.log(OSRM.version);
  ChildProcess.execSync("osmium --version", { stdio: "inherit" });
  ChildProcess.execSync("osrm-customize --version", { stdio: "inherit" });
  ChildProcess.execSync("tilemaker --help", { stdio: "inherit" });


  const response = {
    statusCode: 200,
    body: JSON.stringify('Hello from Lambda!'),
  };
  return response;
};

To Do

  • Split OSRM / Osmium / Tilemaker into individual, combinable layers
  • Add other runtime support (mainly CLI-only option)

Support

This project is a part of my larger work on Skyway.run, an indoor navigation app. If you find aws-lambda-layer-osmtools useful on your project, let me know and I can list you here.

Contributors or sponsors very welcome :)