awslimitchecker.trustedadvisor module¶
-
class
awslimitchecker.trustedadvisor.
TrustedAdvisor
(all_services, account_id=None, account_role=None, region=None, external_id=None, mfa_serial_number=None, mfa_token=None)[source]¶ Bases:
awslimitchecker.connectable.Connectable
Class to contain all TrustedAdvisor-related logic.
Parameters: - all_services (dict) –
AwsLimitChecker
services
dictionary. - account_id (str) – AWS Account ID (12-digit string, currently numeric) for the account to connect to (destination) via STS
- account_role (str) – the name of an IAM Role (in the destination account) to assume
- region (str) – AWS region name to connect to
- external_id (str) – (optional) the External ID string to use when assuming a role via STS.
- mfa_serial_number (str) – (optional) the MFA Serial Number string to use when assuming a role via STS.
- mfa_token (str) – (optional) the MFA Token string to use when assuming a role via STS.
-
__init__
(all_services, account_id=None, account_role=None, region=None, external_id=None, mfa_serial_number=None, mfa_token=None)[source]¶ Class to contain all TrustedAdvisor-related logic.
Parameters: - all_services (dict) –
AwsLimitChecker
services
dictionary. - account_id (str) –
AWS Account ID (12-digit string, currently numeric) for the account to connect to (destination) via STS
- account_role (str) –
the name of an IAM Role (in the destination account) to assume
- region (str) – AWS region name to connect to
- external_id (str) –
(optional) the External ID string to use when assuming a role via STS.
- mfa_serial_number (str) – (optional) the MFA Serial Number string to use when assuming a role via STS.
- mfa_token (str) – (optional) the MFA Token string to use when assuming a role via STS.
- all_services (dict) –
-
__module__
= 'awslimitchecker.trustedadvisor'¶
-
_get_limit_check_id
()[source]¶ Query currently-available TA checks, return the check ID and metadata of the ‘performance/Service Limits’ check.
Returns: 2-tuple of Service Limits TA check ID (string), metadata (list), or (None, None). Return type: tuple
-
_make_ta_service_dict
()[source]¶ Build our service and limits dict. This is laid out identical to
self.all_services
, but keys limits by theirta_service_name
andta_limit_name
properties.Returns: dict of TA service names to TA limit names to AwsLimit objects.
-
_poll
()[source]¶ Poll Trusted Advisor (Support) API for limit checks.
Return a dict of service name (string) keys to nested dict vals, where each key is a limit name and each value the current numeric limit.
e.g.:
{ 'EC2': { 'SomeLimit': 10, } }
-
_update_services
(ta_results)[source]¶ Given a dict of TrustedAdvisor check results from
_poll()
and a dict of Service objects passed in toupdate_limits()
, updated the TrustedAdvisor limits for all services.Parameters:
-
api_name
= 'support'¶
-
service_name
= 'TrustedAdvisor'¶
-
update_limits
()[source]¶ Poll ‘Service Limits’ check results from Trusted Advisor, if possible. Iterate over all
AwsLimit
objects for the given services and update their limits from TA if present in TA checks.Parameters: services (dict) – dict of service name (string) to _AwsService
objects
- all_services (dict) –