s3_env

Contents

s3_env#

s3_env(*args, **kwargs)[source]#

Create S3 compatible storage environment 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):

  1. AWS profile

  2. Given endpoint_url as function argument

  3. AWS environment variable

Returns:

decorated function

Return type:

Callable

Example

>>> from sertit.s3 import s3_env
>>> from sertit import AnyPath
>>> @s3_env(endpoint="s3.unistra.fr")
>>> def file_exists(path: str):
>>>     pth = AnyPath(path)
>>>     print(pth.exists())
>>> file_exists("s3://sertit-geodatastore/GLOBAL/COPDEM_30m/COPDEM_30m.vrt")
True