awslimitchecker.services.base module¶
-
class
awslimitchecker.services.base.
_AwsService
(warning_threshold, critical_threshold, account_id=None, account_role=None, region=None, external_id=None, mfa_serial_number=None, mfa_token=None)[source]¶ Bases:
awslimitchecker.connectable.Connectable
Describes an AWS service and its limits, and provides methods to query current utilization.
Constructors of _AwsService subclasses must not make any external connections; these must be made lazily as needed in other methods. _AwsService subclasses should be usable without any external network connections.
Parameters: - warning_threshold (int) – the default warning threshold, as an integer percentage, for any limits without a specifically-set threshold.
- critical_threshold (int) – the default critical threshold, as an integer percentage, for any limits without a specifically-set threshold.
- 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.
-
__abstractmethods__
= frozenset(['get_limits', 'find_usage', 'required_iam_permissions'])¶
-
__init__
(warning_threshold, critical_threshold, account_id=None, account_role=None, region=None, external_id=None, mfa_serial_number=None, mfa_token=None)[source]¶ Describes an AWS service and its limits, and provides methods to query current utilization.
Constructors of _AwsService subclasses must not make any external connections; these must be made lazily as needed in other methods. _AwsService subclasses should be usable without any external network connections.
Parameters: - warning_threshold (int) – the default warning threshold, as an integer percentage, for any limits without a specifically-set threshold.
- critical_threshold (int) – the default critical threshold, as an integer percentage, for any limits without a specifically-set threshold.
- 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.
-
__metaclass__
¶ alias of
ABCMeta
-
__module__
= 'awslimitchecker.services.base'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 25¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_set_ta_limit
(limit_name, value)[source]¶ Set the value for the limit as reported by Trusted Advisor, for the specified limit.
This method should only be called by
TrustedAdvisor
.Parameters: Raises: ValueError if limit_name is not known to this service
-
api_name
= 'baseclass'¶
-
check_thresholds
()[source]¶ Checks current usage against configured thresholds for all limits for this service.
Returns: a dict of limit name to AwsLimit
instance for all limits that crossed one or more of their thresholds.Return type: dict
ofAwsLimit
-
find_usage
()[source]¶ Determine the current usage for each limit of this service, and update the
current_usage
property of each correspondingAwsLimit
instance.This method MUST set
self._have_usage = True
.If the boto3 method being called returns a dict response that can include ‘NextToken’ or another pagination marker, it should be called through
paginate_dict()
with the appropriate parameters.
-
get_limits
()[source]¶ Return all known limits for this service, as a dict of their names to
AwsLimit
objects.All limits must have
self.warning_threshold
andself.critical_threshold
passed into them.Returns: dict of limit names to AwsLimit
objectsReturn type: dict
-
required_iam_permissions
()[source]¶ Return a list of IAM Actions required for this Service to function properly. All Actions will be shown with an Effect of “Allow” and a Resource of “*”.
Returns: list of IAM Action strings Return type: list
-
service_name
= 'baseclass'¶
-
set_limit_override
(limit_name, value, override_ta=True)[source]¶ Set a new limit
value
for the specified limit, overriding the default. Ifoverride_ta
is True, also use this value instead of any found by Trusted Advisor. This method simply passes the data through to theset_limit_override()
method of the underlyingAwsLimit
instance.Parameters: Raises: ValueError if limit_name is not known to this service
-
set_threshold_override
(limit_name, warn_percent=None, warn_count=None, crit_percent=None, crit_count=None)[source]¶ Override the default warning and critical thresholds used to evaluate the specified limit’s usage. Theresholds can be specified as a percentage of the limit, or as a usage count, or both.
Parameters: