Skip to content

Commit 06f9e84

Browse files
committed
Should address issue nficano#38. The calls to determine whether or not a function exists wasn't calling multiple times if you have more than 50 lambda functions configured. For those users who have lots of functions defined, the deploy will try to re-create an existing lambda function
1 parent 0dd0754 commit 06f9e84

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

aws_lambda/aws_lambda.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,13 @@ def function_exists(cfg, function_name):
535535
'lambda', aws_access_key_id, aws_secret_access_key,
536536
cfg.get('region'),
537537
)
538-
functions = client.list_functions().get('Functions', [])
539-
for fn in functions:
540-
if fn.get('FunctionName') == function_name:
541-
return True
542-
return False
538+
539+
# Need to loop through until we get all of the lambda functions returned. It appears
540+
# to be only returning 50 functions at a time.
541+
functions = []
542+
functions_resp = client.list_functions()
543+
functions.extend([f['FunctionName'] for f in functions_resp.get('Functions', [])])
544+
while('NextMarker' in functions_resp):
545+
functions_resp = client.list_functions(Marker=functions_resp.get('NextMarker'))
546+
functions.extend([f['FunctionName'] for f in functions_resp.get('Functions', [])])
547+
return function_name in functions

0 commit comments

Comments
 (0)