protomaps / go-pmtiles

Single-file executable tool for working with PMTiles archives
BSD 3-Clause "New" or "Revised" License
350 stars 48 forks source link

Serving from public s3 bucket #165

Closed aLemonFox closed 3 months ago

aLemonFox commented 4 months ago

Hi, I was wondering if it's possible to serve from a public s3 bucket. Per the docs I would guess I had to run: pmtiles serve / --bucket=s3://my_bucket_name and set credentials for environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

However when I try this I get: failed to fetch pm 0-0, blob (key "pm.pmtiles") (code=Unknown): NoCredentialProviders: no valid providers in chain. Deprecated. This is on cloudflare r2.

Since my bucket is public I thought maybe I can just directly pass the url, but this tries to search for the directories locally. It seems like an easy task so am I missing something here?

bdon commented 3 months ago

If your S3 bucket is public it should have a HTTPS URL like https://BUCKET.s3.us-west-2.amazonaws.com/folder , you should be able to use that anywhere you use s3://

Is that a working solution? Otherwise we would need to make the gocloud library accept anonymous credentials.

bdon commented 3 months ago

Example: go run main.go serve . --bucket=https://build.protomaps.com

aLemonFox commented 3 months ago

Thanks, I forgot to put . before --bucket.

bdon commented 3 months ago

Updated docs here: https://github.com/protomaps/docs/pull/36