Reading from custom S3 #1177
-
I have some COGs in a Minio bucket, that are served by a STAC API. I managed to read them by setting the following environment variables as explained in https://gdal.org/en/stable/user/virtual_file_systems.html#configuring-vsis3-with-minio:
Is there a way to configure a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes you should be able to do it using |
Beta Was this translation helpful? Give feedback.
-
I managed to make this work with the following code: import os from rasterio.session import AWSSession AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") AWS_REGION = os.getenv("AWS_REGION") AWS_S3_ENDPOINT = os.getenv("AWS_S3_ENDPOINT") session = AWSSession( aws_unsigned=False, aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region_name=AWS_REGION, endpoint_url=AWS_S3_ENDPOINT, ) def get_session() -> AWSSession: """S3 Session getter.""" return session def get_env_dependency() -> dict: """FastAPI Dependency to retrieve the S3 environment.""" s3_session = get_session() return {"session": s3_session} ###### # Add COG extensions cog = TilerFactory( reader=Reader, router_prefix="/cog", environment_dependency=get_env_dependency, # Passes S3 environment ) with the following environment variables: AWS_ACCESS_KEY_ID = "" AWS_SECRET_ACCESS_KEY = "" AWS_VIRTUAL_HOSTING = "FALSE" AWS_REGION="" # Internal IP # AWS_S3_ENDPOINT = "localhost:1234" # AWS_HTTPS = "NO" # Public domain AWS_S3_ENDPOINT = "s3.example.com" AWS_HTTPS = "YES" |
Beta Was this translation helpful? Give feedback.
I managed to make this work with the following code: