Skip to content

Commit 2c72620

Browse files
authored
Lambda function storage check (#20)
* add new check for lambda function and layer storage
1 parent 55b8418 commit 2c72620

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
### Added
11+
12+
- new check: lambda_function_storage
13+
814
## [1.6.0] - 2021-04-30
915

1016
### Added

aws_quota/check/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .elasticbeanstalk import *
1111
from .elb import *
1212
from .iam import *
13+
from .lambdas import *
1314
from .route53 import *
1415
from .route53resolver import *
1516
from .s3 import *
@@ -18,9 +19,15 @@
1819
from .vpc import *
1920
from .quota_check import QuotaCheck
2021

22+
2123
def __all_subclasses(cls):
2224
return set(cls.__subclasses__()).union(
23-
[s for c in cls.__subclasses__() for s in __all_subclasses(c)])
25+
[s for c in cls.__subclasses__() for s in __all_subclasses(c)]
26+
)
27+
2428

25-
ALL_CHECKS = sorted([clazz for clazz in __all_subclasses(QuotaCheck) if clazz != InstanceQuotaCheck], key=lambda clz: clz.key)
29+
ALL_CHECKS = sorted(
30+
[clazz for clazz in __all_subclasses(QuotaCheck) if clazz != InstanceQuotaCheck],
31+
key=lambda clz: clz.key,
32+
)
2633
ALL_INSTANCE_SCOPED_CHECKS = filter(lambda check: check.scope == QuotaScope.INSTANCE, ALL_CHECKS)

aws_quota/check/lambdas.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from .quota_check import QuotaCheck, QuotaScope
2+
3+
4+
class FunctionAndLayerStorageCheck(QuotaCheck):
5+
key = "lambda_function_storage"
6+
description = "Lambda function and layer storage"
7+
scope = QuotaScope.REGION
8+
service_code = 'lambda'
9+
quota_code = 'L-2ACBD22F'
10+
11+
@property
12+
def current(self):
13+
return (
14+
self.boto_session.client('lambda').get_account_settings()['AccountUsage'][
15+
'TotalCodeSize'
16+
]
17+
/ 1000000000
18+
)

0 commit comments

Comments
 (0)