awslimitchecker.connectable module

class awslimitchecker.connectable.Connectable[source]

Bases: object

Mix-in helper class for connecting to AWS APIs. Centralizes logic of connecting via regions and/or STS.

__dict__ = mappingproxy({'__module__': 'awslimitchecker.connectable', '__doc__': '\n Mix-in helper class for connecting to AWS APIs. Centralizes logic of\n connecting via regions and/or STS.\n ', '_max_retries_config': <property object>, 'connect': <function Connectable.connect>, 'connect_resource': <function Connectable.connect_resource>, '__dict__': <attribute '__dict__' of 'Connectable' objects>, '__weakref__': <attribute '__weakref__' of 'Connectable' objects>})
__module__ = 'awslimitchecker.connectable'
__weakref__

list of weak references to the object (if defined)

_max_retries_config

If a BOTO_MAX_RETRIES_<self.api_name> environment variable is set, return a new botocore.config.Config instance using that number as the retries max_attempts value.

Return type:botocore.config.Config or None
connect()[source]

Connect to an AWS API via boto3 low-level client and set self.conn to the boto3.client object (a botocore.client.* instance). If self.conn is not None, do nothing. This connects to the API name given by self.api_name.

Returns:None
connect_resource()[source]

Connect to an AWS API via boto3 high-level resource connection and set self.resource_conn to the boto3.resource object (a boto3.resources.factory.*.ServiceResource instance). If self.resource_conn is not None, do nothing. This connects to the API name given by self.api_name.

Returns:None
class awslimitchecker.connectable.ConnectableCredentials(creds_dict)[source]

Bases: object

boto’s (2.x) boto.sts.STSConnection.assume_role() returns a boto.sts.credentials.Credentials object, but boto3’s boto3.sts.STSConnection.assume_role just returns a dict. This class provides a compatible interface for boto3.

We also maintain an account_id attribute that can be set to the account ID, to ensure that credentials are updated when switching accounts.

__dict__ = mappingproxy({'__module__': 'awslimitchecker.connectable', '__doc__': "\n boto's (2.x) :py:meth:`boto.sts.STSConnection.assume_role` returns a\n :py:class:`boto.sts.credentials.Credentials` object, but boto3's\n `boto3.sts.STSConnection.assume_role <https://boto3.readthedocs.org/en/\n latest/reference/services/sts.html#STS.Client.assume_role>`_ just returns\n a dict. This class provides a compatible interface for boto3.\n\n We also maintain an ``account_id`` attribute that can be set to the\n account ID, to ensure that credentials are updated when switching accounts.\n ", '__init__': <function ConnectableCredentials.__init__>, '__dict__': <attribute '__dict__' of 'ConnectableCredentials' objects>, '__weakref__': <attribute '__weakref__' of 'ConnectableCredentials' objects>})
__init__(creds_dict)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'awslimitchecker.connectable'
__weakref__

list of weak references to the object (if defined)