Skip to content

Conversation

alamminsalo
Copy link
Contributor

@alamminsalo alamminsalo commented Aug 19, 2024

Added support for s3-urls to config.

This is a bit of a rough sketch currently.
The aws config struct does not seem to support sso-login credentials out of the box, I needed to add the credentials to environment variables along with AWS_REGION to get it working.

Resolves #1171

CommanderStorm

This comment was marked as resolved.

@nyurik
Copy link
Member

nyurik commented Oct 22, 2024

This seems to be almost ready! The biggest challenge is ... sadly... how to test it? I wonder if we should set up some public s3 bucket with some small dummy pmtiles and use it in all the testing? @birkskyum @louwers any thoughts on where we can place it?

P.S. please rebase

@louwers
Copy link
Member

louwers commented Oct 22, 2024

@nyurik
Copy link
Member

nyurik commented Oct 22, 2024

@louwers why is a public readonly s3 bucket with only a small downloadable is a bad idea? Seems like it would be no different than exposing that same bucket with the http interface, and it would let us test s3 API

@louwers
Copy link
Member

louwers commented Oct 22, 2024

@nyurik I misunderstood and removed my earlier comment, I thought we need a S3 bucket for various kinds of test assets. Please use the link I provided! :)

@nyurik
Copy link
Member

nyurik commented Oct 22, 2024

@louwers we do want to upload a bunch of test assets to an s3 bucket (by an admin), but that bucket would be used as a readonly source when running CI tests

@nyurik
Copy link
Member

nyurik commented Oct 22, 2024

@louwers the link you posted above - do you have a full s3:// path to it?

@louwers
Copy link
Member

louwers commented Oct 22, 2024

That would be s3://pmtilestest/cb_2018_us_zcta510_500k.pmtiles

Copy link
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nits about formatting in the docs

@alamminsalo
Copy link
Contributor Author

alamminsalo commented Nov 13, 2024

I migrated to using pmtiles aws-s3-async feature, which uses aws-sdk-s3 and aws-config libraries.
They have better credentials configuration flexibility (eg. can use SSO credentials) and does not need the AWS_REGION environment variable to be set explicitly (can be also defined in profiles).
The support for them seems to have landed in pmtiles 0.11.

Edit: also added tests for the S3 backed based on your suggestions

@CommanderStorm
Copy link
Member

The testcase for grcov is failing..

image

You likely need the same environment variables here:

CARGO_INCREMENTAL: '0'

@Youssef-Harby
Copy link
Contributor

Hi @CommanderStorm and @nyurik, all builds and tests have passed successfully on this run: https://github.com/Youssef-Harby/martin/actions/runs/15181986547 ... When you have a moment, could you please review and let me know the preferred next steps? I'm happy to open a new PR if needed, or feel free to take the necessary changes directly from my fork/branch .. whichever works best for you. Thanks!

@Youssef-Harby
Copy link
Contributor

I noticed that Martin was having difficulty connecting to S3-compatible services like MinIO when using S3 URLs. The issue was that S3-compatible services often require path-style addressing rather than virtual host addressing.

I have added some modifications to check forAWS_S3_FORCE_PATH_STYLE=1 environment variable here Youssef-Harby/martin@31938ca , which enables path-style addressing for S3 connections. This allows Martin to work seamlessly with both AWS S3 and S3-compatible services like MinIO.

The implementation reads the environment variable once during client initialization and applies the setting only when needed.

I don't have a public s3 pmtiles with custom endpoint url to develop a test case .. so will need your feedback on this..
Thank you!

Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Overall seems reasonable. One concern I have is that all of a sudden we rely on the environment variables for pmtiles, while PG sources have a corresponding config value. Does S3 allow query-style params? We could remove them too of course:

s3://bucket/path/to/tiles.pmtiles?AWS_NO_CREDENTIALS=1

#[cfg(any(feature = "pmtiles", feature = "mbtiles", feature = "cog"))]
fn is_url(s: &str, extension: &[&str]) -> bool {
if s.starts_with("http") {
if s.starts_with("http") || s.starts_with("s3") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i keep wondering if we even need this optimization - if this function is only used for parsing, we might as well just parse the URL and check the schema. Also, why do we parse the url here, and also have parse_url? I probably did it a while back, but not sure if this duplicity is needed

@CommanderStorm
Copy link
Member

Does S3 allow query-style params?

Not to my knowlege.
We could add a non-standard query parameter, but uuh.. that seems like a horrible hack.

I can add a config option for both if you'd like.
Given how much changes have gone into this PR, I would like to do this from a blank slate in a new PR if possible.
Much simpler to review.

@CommanderStorm CommanderStorm enabled auto-merge (squash) May 22, 2025 22:38
Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks everyone, well done, and long overdue :) Once we have a few minor follow-up polishes, let's do a release


#[cfg(feature = "pmtiles")]
#[error(r"PMTiles error {0} processing {1}")]
#[error(r"PMTiles error {0:?} processing {1}")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit of a surprising change, but not a biggie

@CommanderStorm CommanderStorm merged commit e55dc5b into maplibre:main May 22, 2025
20 checks passed
CommanderStorm added a commit that referenced this pull request May 30, 2025
…e}` (#1848)

this PR is the followup talked about in #1477

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yuri Astrakhan <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement PMTiles S3 bucket support with authentication
5 participants