awslimitchecker.trustedadvisor module¶
-
class
awslimitchecker.trustedadvisor.TrustedAdvisor(all_services, profile_name=None, account_id=None, account_role=None, region=None, external_id=None, mfa_serial_number=None, mfa_token=None)[source]¶ Bases:
awslimitchecker.connectable.ConnectableClass to contain all TrustedAdvisor-related logic.
Parameters: - all_services (dict) –
AwsLimitCheckerservicesdictionary. - profile_name (str) – The name of a profile in the cross-SDK shared credentials file for boto3 to retrieve AWS credentials from.
- 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, profile_name=None, 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) –
AwsLimitCheckerservicesdictionary. - profile_name (str) –
The name of a profile in the cross-SDK shared credentials file for boto3 to retrieve AWS credentials from.
- 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_nameandta_limit_nameproperties.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
AwsLimitobjects for the given services and update their limits from TA if present in TA checks.Parameters: services (dict) – dict of service name (string) to _AwsServiceobjects
- all_services (dict) –