toil.lib.aws.session
¶
Module Contents¶
Classes¶
Class that represents a connection to AWS. Caches Boto 3 and Boto 2 objects |
Functions¶
|
Get a Boto 3 session usable by the current thread. |
|
Get a Boto 3 client for a particular AWS service, usable by the current thread. |
|
Get a Boto 3 resource for a particular AWS service, usable by the current thread. |
Attributes¶
- toil.lib.aws.session.logger¶
- class toil.lib.aws.session.AWSConnectionManager¶
Class that represents a connection to AWS. Caches Boto 3 and Boto 2 objects by region.
Access to any kind of item goes through the particular method for the thing you want (session, resource, service, Boto2 Context), and then you pass the region you want to work in, and possibly the type of thing you want, as arguments.
This class is intended to eventually enable multi-region clusters, where connections to multiple regions may need to be managed in the same provisioner.
We also support None for a region, in which case no region will be passed to Boto/Boto3. The caller is responsible for implementing e.g. TOIL_AWS_REGION support.
Since connection objects may not be thread safe (see <https://boto3.amazonaws.com/v1/documentation/api/1.14.31/guide/session.html#multithreading-or-multiprocessing-with-sessions>), one is created for each thread that calls the relevant lookup method.
- session(region)¶
Get the Boto3 Session to use for the given region.
- Parameters:
region (Optional[str])
- Return type:
boto3.session.Session
- resource(region, service_name, endpoint_url=None)¶
Get the Boto3 Resource to use with the given service (like ‘ec2’) in the given region.
- client(region, service_name, endpoint_url=None, config=None)¶
Get the Boto3 Client to use with the given service (like ‘ec2’) in the given region.
- toil.lib.aws.session.establish_boto3_session(region_name=None)¶
Get a Boto 3 session usable by the current thread.
This function may not always establish a new session; it can be memoized.
- Parameters:
region_name (Optional[str])
- Return type:
boto3.Session
- toil.lib.aws.session.client(service_name, region_name=None, endpoint_url=None, config=None)¶
Get a Boto 3 client for a particular AWS service, usable by the current thread.
Global alternative to AWSConnectionManager.
- toil.lib.aws.session.resource(service_name, region_name=None, endpoint_url=None)¶
Get a Boto 3 resource for a particular AWS service, usable by the current thread.
Global alternative to AWSConnectionManager.