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__ = dict_proxy({'connect_via': <function connect_via at 0x7fede7532d70>, '__module__': 'awslimitchecker.connectable', '_get_sts_token': <function _get_sts_token at 0x7fede7532de8>, '__dict__': <attribute '__dict__' of 'Connectable' objects>, 'credentials': None, '__weakref__': <attribute '__weakref__' of 'Connectable' objects>, '__doc__': '\n Mix-in helper class for connecting to AWS APIs. Centralizes logic of\n connecting via regions and/or STS.\n '})
__module__ = 'awslimitchecker.connectable'
__weakref__

list of weak references to the object (if defined)

_get_sts_token()[source]

Assume a role via STS and return the credentials.

First connect to STS via boto.sts.connect_to_region(), then assume a role using boto.sts.STSConnection.assume_role() using self.account_id and self.account_role (and optionally self.external_id, self.mfa_serial_number, self.mfa_token). Return the resulting boto.sts.credentials.Credentials object.

Returns:STS assumed role credentials
Return type:boto.sts.credentials.Credentials
connect_via(driver)[source]

Connect to an AWS API and return the connection object. If self.account_id is None, call driver(self.region). Otherwise, call _get_sts_token() to get STS token credentials using boto.sts.STSConnection.assume_role() and call driver() with those credentials to use an assumed role.

Parameters:driver (function) – the connect_to_region() function of the boto submodule to use to create this connection
Returns:connected boto service class instance
credentials = None