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({'__module__': 'awslimitchecker.connectable', '_get_sts_token': <function _get_sts_token at 0x7f29273a0f50>, 'connect': <function connect at 0x7f29273a0e60>, '__dict__': <attribute '__dict__' of 'Connectable' objects>, 'credentials': None, '_boto3_connection_kwargs': <property object at 0x7f29273a1208>, '__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 ', 'connect_resource': <function connect_resource at 0x7f29273a0ed8>})¶
-
__module__
= 'awslimitchecker.connectable'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_boto3_connection_kwargs
¶ Generate keyword arguments for boto3 connection functions. If
self.account_id
is None, this will just includeregion_name=self.region
. Otherwise, call_get_sts_token()
to get STS token credentials using boto3.STS.Client.assume_role and include those credentials in the return value.Returns: keyword arguments for boto3 connection functions Return type: dict
-
_get_sts_token
()[source]¶ Assume a role via STS and return the credentials.
First connect to STS via
boto3.client()
, then assume a role using boto3.STS.Client.assume_role usingself.account_id
andself.account_role
(and optionallyself.external_id
,self.mfa_serial_number
,self.mfa_token
). Return the resultingConnectableCredentials
object.Returns: STS assumed role credentials Return type: ConnectableCredentials
-
connect
()[source]¶ Connect to an AWS API via boto3 low-level client and set
self.conn
to the boto3.client object (abotocore.client.*
instance). Ifself.conn
is not None, do nothing. This connects to the API name given byself.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 (aboto3.resources.factory.*.ServiceResource
instance). Ifself.resource_conn
is not None, do nothing. This connects to the API name given byself.api_name
.Returns: None
-
credentials
= None¶
-
-
class
awslimitchecker.connectable.
ConnectableCredentials
(creds_dict)[source]¶ Bases:
object
boto’s (2.x)
boto.sts.STSConnection.assume_role()
returns aboto.sts.credentials.Credentials
object, but boto3’s boto3.sts.STSConnection.assume_role just returns a dict. This class provides a compatible interface for boto3.-
__dict__
= dict_proxy({'__dict__': <attribute '__dict__' of 'ConnectableCredentials' objects>, '__module__': 'awslimitchecker.connectable', '__weakref__': <attribute '__weakref__' of 'ConnectableCredentials' objects>, '__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 ", '__init__': <function __init__ at 0x7f29273a0d70>})¶
-
__module__
= 'awslimitchecker.connectable'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-