maplibre / martin

Blazing fast and lightweight PostGIS, MBtiles and PMtiles tile server, tile generation, and mbtiles tooling.
https://martin.maplibre.org
Apache License 2.0
2.29k stars 215 forks source link

Implement PMTiles S3 bucket support with authentication #1171

Open nyurik opened 9 months ago

nyurik commented 9 months ago

pmtiles crate will soon support s3 buckets directly. Martin needs to enable support for S3-hosted pmtiles

TODO

Developers can already use by adding this at the end of the root Cargo.toml:

[patch.crates-io]
pmtiles = { git = "https://github.com/stadiamaps/pmtiles-rs", branch = "add-s3-backend" }

See also https://github.com/maplibre/martin/discussions/1125 CC: @alexjball @lseelenbinder

nyurik commented 9 months ago

for configuration, we currently have this pattern:

pmtiles:
  paths:
    # scan this whole dir, matching all *.pmtiles files
    - /dir-path
    # specific pmtiles file will be published as a pmt source (filename without extension)
    - /path/to/pmt.pmtiles
    # A web server with a PMTiles file that supports range requests
    - https://example.org/path/tiles.pmtiles
  sources:
    # named source matching source name to a single file
    pm-src1: /path/to/pmt.pmtiles
    # A named source to a web server with a PMTiles file that supports range requests
    pm-web2: https://example.org/path/tiles.pmtiles

We can add s3 support as either an s3 subsection under pmtiles, or by adding a new top level pmtiles-s3. I think the first option is better, but it might be trickier to implement.

pmtiles:
  s3:
    [...something...]

pmtiles-s3:
    [...something...]

Config should cover the following cases:

So it seems the usage is similar to postgres configuration, where we can have one or more pg connection (i.e. s3 authentication), and each connection can have one or more table (i.e. pmtiles files), and the table name can be declared in the config (with the corresponding source name), or they can be auto-discovered, in which case the source name is auto-generated, e.g. {filename} or {bucket}_{filename}.

jleedev commented 9 months ago

The protomaps/PMTiles supports specifying a bucket (and a path prefix), and allows fetching any pmtiles object by name, rather than having to specify them all ahead of time, or listing the objects. Would require some refactoring here, but it's a sensible way to avoid expensive reconfigurations.

jtmiclat commented 5 months ago

Hi! I would be interested in implementing this if noone has started on it yet!

nyurik commented 5 months ago

we have some s3 support in place, but nothing with auth as far as i know, and I don't know anyone working on this at the moment. @jleedev was the only person who also worked on it in the merged #1127