File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 19
19
20
20
21
21
def main ():
22
- lambdas = Lambdas ().list_lambdas ()
22
+ lambdas = Lambdas ().list_deployment_lambdas ()
23
23
for lambda_ in lambdas :
24
- response = aws .lambda_ .list_versions_by_function (
25
- FunctionName = lambda_ .name
26
- )
24
+ log .info ('Fetching the published versions of %s' , lambda_ .name )
25
+ response = aws .lambda_ .list_versions_by_function (FunctionName = lambda_ .name )
27
26
for version in response ['Versions' ]:
28
- if version ['Version' ] == '$LATEST' :
27
+ version = version ['Version' ]
28
+ if version == '$LATEST' :
29
29
pass
30
30
else :
31
- version_number = version ['Version' ]
32
- log .info ('Deleting published version %s of %s' , version_number , lambda_ .name )
31
+ log .info ('Deleting published version %s of %s' , version , lambda_ .name )
33
32
aws .lambda_ .delete_function (
34
33
FunctionName = lambda_ .name ,
35
- Qualifier = version_number
34
+ Qualifier = version
36
35
)
37
36
38
37
Original file line number Diff line number Diff line change @@ -98,12 +98,27 @@ def _lambda(self):
98
98
return aws .lambda_
99
99
100
100
def list_lambdas (self ) -> list [Lambda ]:
101
+ """
102
+ Return a list of all the Lambda functions in the AWS project
103
+ """
101
104
return [
102
105
Lambda .from_response (function )
103
106
for response in self ._lambda .get_paginator ('list_functions' ).paginate ()
104
107
for function in response ['Functions' ]
105
108
]
106
109
110
+ def list_deployment_lambdas (self ) -> list [Lambda ]:
111
+ """
112
+ Return a list of all the Lambda functions that are part of the currently
113
+ selected deployment.
114
+ """
115
+ return [
116
+ Lambda .from_response (function )
117
+ for response in self ._lambda .get_paginator ('list_functions' ).paginate ()
118
+ for function in response ['Functions' ]
119
+ if function ['Environment' ]['Variables' ]['AZUL_DEPLOYMENT_STAGE' ] == config .deployment_stage
120
+ ]
121
+
107
122
def manage_lambdas (self , enabled : bool ):
108
123
paginator = self ._lambda .get_paginator ('list_functions' )
109
124
lambda_prefixes = [config .qualified_resource_name (lambda_infix ) for lambda_infix in config .lambda_names ()]
Original file line number Diff line number Diff line change @@ -709,8 +709,8 @@ def tf_config(self, app_name):
709
709
assert 'layers' not in resource
710
710
resource ['layers' ] = ['${aws_lambda_layer_version.dependencies.arn}' ]
711
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.
712
+ # race conditions when there's a cyclic dependency between an update
713
+ # to the function's configuration and an update to its code
714
714
resource ['publish' ] = True
715
715
env = config .es_endpoint_env (
716
716
es_endpoint = (
You can’t perform that action at this time.
0 commit comments