Skip to content

Commit

Permalink
PR jantman#366 - define all limits in _construct_limits and unify Tot…
Browse files Browse the repository at this point in the history
…al Code Size to MiB
  • Loading branch information
jantman authored and nadlerjessie committed Feb 16, 2019
1 parent 77fd7e3 commit 38c63e2
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions awslimitchecker/services/lambdafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,10 @@ def find_usage(self):
except EndpointConnectionError as ex:
logger.warn('Skipping Lambda: %s', str(ex))
return

self.limits = {}

self.limits['Function Count'] = AwsLimit(
'Function Count',
self,
None,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::Lambda::Function'
)
self.limits['Function Count']._add_current_usage(
resp['AccountUsage']['FunctionCount'])

self.limits['Total Code Size (MiB)'] = AwsLimit(
'Total Code Size (MiB)',
self,
76800,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::Lambda::Function')
self.limits['Total Code Size (MiB)']._add_current_usage(
int((resp['AccountUsage']['TotalCodeSize'])/1048576))

self._have_usage = True

def get_limits(self):
Expand Down Expand Up @@ -117,8 +97,8 @@ def _update_limits_from_api(self):
return
self.connect()
lims = self.conn.get_account_settings()['AccountLimit']
self.limits['Total Code Size (GiB)']._set_api_limit(
(lims['TotalCodeSize']/1073741824))
self.limits['Total Code Size (MiB)']._set_api_limit(
(lims['TotalCodeSize']/1048576))
self.limits['Code Size Unzipped (MiB) per Function']._set_api_limit(
(lims['CodeSizeUnzipped']/1048576))
self.limits['Unreserved Concurrent Executions']._set_api_limit(
Expand All @@ -130,10 +110,10 @@ def _update_limits_from_api(self):

def _construct_limits(self):
self.limits = {}
self.limits['Total Code Size (GiB)'] = AwsLimit(
'Total Code Size (GiB)',
self.limits['Total Code Size (MiB)'] = AwsLimit(
'Total Code Size (MiB)',
self,
75,
76800,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::Lambda::Function'
Expand All @@ -148,7 +128,6 @@ def _construct_limits(self):
limit_type='AWS::Lambda::Function'
)

# if 'Unreserved Concurrent Executions' in limits:
self.limits['Unreserved Concurrent Executions'] = AwsLimit(
'Unreserved Concurrent Executions',
self,
Expand All @@ -158,7 +137,6 @@ def _construct_limits(self):
limit_type='AWS::Lambda::Function'
)

# if 'Concurrent Executions' in limits:
self.limits['Concurrent Executions'] = AwsLimit(
'Concurrent Executions',
self,
Expand All @@ -168,7 +146,6 @@ def _construct_limits(self):
limit_type='AWS::Lambda::Function'
)

# if 'Code Size Zipped' in limits:
self.limits['Code Size Zipped (MiB) per Function'] = AwsLimit(
'Code Size Zipped (MiB) per Function',
self,
Expand All @@ -178,6 +155,15 @@ def _construct_limits(self):
limit_type='AWS::Lambda::Function'
)

self.limits['Function Count'] = AwsLimit(
'Function Count',
self,
None, # unlimited
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::Lambda::Function'
)

def required_iam_permissions(self):
"""
Return a list of IAM Actions required for this Service to function
Expand Down

0 comments on commit 38c63e2

Please sign in to comment.