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 0x7ff84635dd70>, '__module__': 'awslimitchecker.connectable', '_get_sts_token': <function _get_sts_token at 0x7ff84635dde8>, '__dict__': <attribute '__dict__' of 'Connectable' objects>, '__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'

list of weak references to the object (if defined)


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). Return the resulting boto.sts.credentials.Credentials object.

Returns:STS assumed role credentials
Return type:boto.sts.credentials.Credentials

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