drivendataorg / cloudpathlib

Python pathlib-style classes for cloud storage services such as Amazon S3, Azure Blob Storage, and Google Cloud Storage.
https://cloudpathlib.drivendata.org
MIT License
420 stars 49 forks source link

Allow to pass boto3 client to S3Client #435

Open abourramouss opened 1 month ago

abourramouss commented 1 month ago

Currently the S3Client needs the credentials to be used, but what happens if i already have a boto3 client somewhere initialized and i want to use the S3Client class?

Is it possible to allow for the S3Client to take a boto3 client that has already been created? It would be simply passing the client at the constructor

pjbull commented 1 month ago

I think it should be possible. It may also require that you pass the session as well (which we currently support).

Out of curiosity, what is the scenario where you already have a client? What parameters are you using in constructing the client that you can't use with the current instantiation approach?

abourramouss commented 1 month ago

Out of curiosity, what is the scenario where you already have a client? What parameters are you using in constructing the client that you can't use with the current instantiation approach?

I use the Lithops framework to execute serverless functions. Lithops has a storage class, and this storage class is just a wrapper around boto3, Lithops exposes a get_client from whom i could get the boto3 client.

The idea of course is that Lithops has it's own config file and from where initializes everything, and to not pass the credentials through the code, it would be interesting to initialize the S3Client with the boto3 client.

https://github.com/lithops-cloud/lithops/