Skip to content

Reading from custom S3 #1177

Closed Answered by guillemc23
guillemc23 asked this question in Q&A
Jun 20, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

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 = ge…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@guillemc23
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by guillemc23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants