File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ $(1)terraform: lambdas
99
99
100
100
.PHONY: $(1 ) deploy
101
101
$(1 ) deploy: check_python $(1 ) terraform
102
+ python $(project_root ) /scripts/delete_lambda_versions.py
102
103
python $(project_root ) /scripts/post_deploy_tdr.py
103
104
endef
104
105
Original file line number Diff line number Diff line change
1
+ """
2
+ Delete all published AWS Lambda versions except for "$LATEST" in the current
3
+ deployment.
4
+ """
5
+
6
+ import logging
7
+
8
+ from azul .deployment import (
9
+ aws ,
10
+ )
11
+ from azul .lambdas import (
12
+ Lambdas ,
13
+ )
14
+ from azul .logging import (
15
+ configure_script_logging ,
16
+ )
17
+
18
+ log = logging .getLogger (__name__ )
19
+
20
+
21
+ def main ():
22
+ lambdas = Lambdas ().list_lambdas ()
23
+ for lambda_ in lambdas :
24
+ response = aws .lambda_ .list_versions_by_function (
25
+ FunctionName = lambda_ .name
26
+ )
27
+ for version in response ['Versions' ]:
28
+ if version ['Version' ] == '$LATEST' :
29
+ pass
30
+ else :
31
+ version_number = version ['Version' ]
32
+ log .info ('Deleting published version %s of %s' , version_number , lambda_ .name )
33
+ aws .lambda_ .delete_function (
34
+ FunctionName = lambda_ .name ,
35
+ Qualifier = version_number
36
+ )
37
+
38
+
39
+ if __name__ == '__main__' :
40
+ configure_script_logging (log )
41
+ main ()
Original file line number Diff line number Diff line change @@ -708,6 +708,10 @@ def tf_config(self, app_name):
708
708
for resource in resources ['aws_lambda_function' ].values ():
709
709
assert 'layers' not in resource
710
710
resource ['layers' ] = ['${aws_lambda_layer_version.dependencies.arn}' ]
711
+ # Publishing the Lambda function as a new version prevents possible
712
+ # race conditions when an update to the function's configuration and
713
+ # code rely on the update of each other in order to work correctly.
714
+ resource ['publish' ] = True
711
715
env = config .es_endpoint_env (
712
716
es_endpoint = (
713
717
aws .es_endpoint
You can’t perform that action at this time.
0 commit comments