@@ -109,7 +109,7 @@ def deploy(
109
109
local_package = local_package ,
110
110
)
111
111
112
- if function_exists (cfg , cfg . get ( 'function_name' ) ):
112
+ if function_exists (cfg ):
113
113
update_function (cfg , path_to_zip_file )
114
114
else :
115
115
create_function (cfg , path_to_zip_file )
@@ -143,7 +143,7 @@ def deploy_s3(
143
143
144
144
use_s3 = True
145
145
s3_file = upload_s3 (cfg , path_to_zip_file , use_s3 )
146
- if function_exists (cfg , cfg . get ( 'function_name' ) ):
146
+ if function_exists (cfg ):
147
147
update_function (cfg , path_to_zip_file , use_s3 = use_s3 , s3_file = s3_file )
148
148
else :
149
149
create_function (cfg , path_to_zip_file , use_s3 = use_s3 , s3_file = s3_file )
@@ -663,9 +663,10 @@ def upload_s3(cfg, path_to_zip_file, *use_s3):
663
663
return filename
664
664
665
665
666
- def function_exists (cfg , function_name ):
666
+ def function_exists (cfg ):
667
667
"""Check whether a function exists or not"""
668
668
669
+ function_name = cfg .get ('function_name' )
669
670
profile_name = cfg .get ('profile' )
670
671
aws_access_key_id = cfg .get ('aws_access_key_id' )
671
672
aws_secret_access_key = cfg .get ('aws_secret_access_key' )
@@ -674,22 +675,11 @@ def function_exists(cfg, function_name):
674
675
cfg .get ('region' ),
675
676
)
676
677
677
- # Need to loop through until we get all of the lambda functions returned.
678
- # It appears to be only returning 50 functions at a time.
679
- functions = []
680
- functions_resp = client .list_functions ()
681
- functions .extend ([
682
- f ['FunctionName' ] for f in functions_resp .get ('Functions' , [])
683
- ])
684
- while ('NextMarker' in functions_resp ):
685
- functions_resp = client .list_functions (
686
- Marker = functions_resp .get ('NextMarker' ),
687
- )
688
- functions .extend ([
689
- f ['FunctionName' ] for f in functions_resp .get ('Functions' , [])
690
- ])
691
- return function_name in functions
692
-
678
+ try :
679
+ return client .get_function (FunctionName = function_name )
680
+ except client .exceptions .ResourceNotFoundException as e :
681
+ if 'Function not found' in str (e ):
682
+ return False
693
683
694
684
def read_cfg (path_to_config_file , profile_name ):
695
685
cfg = read (path_to_config_file , loader = yaml .load )
0 commit comments