temp_s3#
- temp_s3(endpoint: str = None, profile_name: str = None, requester_pays: bool = False, no_sign_request: bool = False, **kwargs) None [source]#
Initialize a temporary S3 environment as a context manager You need to set endpoint url if you use s3 compatible storage since GDAL/Rasterio does not read endpoint url from config file.
This function searches for S3 configuration in many places. It does apply configuration variables precedence, and you might have a use for it. Here is the order of precedence from least to greatest (the last listed configuration variables override all other variables):
AWS profile
Given endpoint_url as function argument
AWS environment variable
- Parameters:
Example
>>> from sertit.s3 import temp_s3 >>> from sertit import AnyPath >>> def file_exists(path: str): >>> with temp_s3(endpoint="s3.unistra.fr"): >>> pth = AnyPath(path) >>> print(pth.exists()) >>> file_exists("s3://sertit-geodatastore/GLOBAL/COPDEM_30m/COPDEM_30m.vrt") True