temp_s3

Contents

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):

  1. AWS profile

  2. Given endpoint_url as function argument

  3. AWS environment variable

Parameters:
  • endpoint – Endpoint to s3 path in the form s3.yourdomain.com

  • profile_name – The name of your AWS profile

  • requester_pays (bool) – True if the endpoint says ‘requester pays’

  • no_sign_request (bool) – True if the endpoint is open access

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