3333log = logging .getLogger (__name__ )
3434
3535
36- def cleanup_old_versions (src , keep_last_versions ):
36+ def cleanup_old_versions (src , keep_last_versions , config_file = 'config.yaml' ):
3737 """Deletes old deployed versions of the function in AWS Lambda.
3838
3939 Won't delete $Latest and any aliased version
@@ -47,7 +47,7 @@ def cleanup_old_versions(src, keep_last_versions):
4747 if keep_last_versions <= 0 :
4848 print ("Won't delete all versions. Please do this manually" )
4949 else :
50- path_to_config_file = os .path .join (src , 'config.yaml' )
50+ path_to_config_file = os .path .join (src , config_file )
5151 cfg = read (path_to_config_file , loader = yaml .load )
5252
5353 aws_access_key_id = cfg .get ('aws_access_key_id' )
@@ -78,7 +78,7 @@ def cleanup_old_versions(src, keep_last_versions):
7878 .format (version_number , e .message ))
7979
8080
81- def deploy (src , requirements = False , local_package = None ):
81+ def deploy (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
8282 """Deploys a new function to AWS Lambda.
8383
8484 :param str src:
@@ -89,7 +89,7 @@ def deploy(src, requirements=False, local_package=None):
8989 well (and/or is not available on PyPi)
9090 """
9191 # Load and parse the config file.
92- path_to_config_file = os .path .join (src , 'config.yaml' )
92+ path_to_config_file = os .path .join (src , config_file )
9393 cfg = read (path_to_config_file , loader = yaml .load )
9494
9595 # Copy all the pip dependencies required to run your code into a temporary
@@ -104,7 +104,7 @@ def deploy(src, requirements=False, local_package=None):
104104 create_function (cfg , path_to_zip_file )
105105
106106
107- def deploy_s3 (src , requirements = False , local_package = None ):
107+ def deploy_s3 (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
108108 """Deploys a new function via AWS S3.
109109
110110 :param str src:
@@ -115,7 +115,7 @@ def deploy_s3(src, requirements=False, local_package=None):
115115 well (and/or is not available on PyPi)
116116 """
117117 # Load and parse the config file.
118- path_to_config_file = os .path .join (src , 'config.yaml' )
118+ path_to_config_file = os .path .join (src , config_file )
119119 cfg = read (path_to_config_file , loader = yaml .load )
120120
121121 # Copy all the pip dependencies required to run your code into a temporary
@@ -132,7 +132,7 @@ def deploy_s3(src, requirements=False, local_package=None):
132132 create_function (cfg , path_to_zip_file , use_s3 , s3_file )
133133
134134
135- def upload (src , requirements = False , local_package = None ):
135+ def upload (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
136136 """Uploads a new function to AWS S3.
137137
138138 :param str src:
@@ -143,7 +143,7 @@ def upload(src, requirements=False, local_package=None):
143143 well (and/or is not available on PyPi)
144144 """
145145 # Load and parse the config file.
146- path_to_config_file = os .path .join (src , 'config.yaml' )
146+ path_to_config_file = os .path .join (src , config_file )
147147 cfg = read (path_to_config_file , loader = yaml .load )
148148
149149 # Copy all the pip dependencies required to run your code into a temporary
@@ -155,7 +155,7 @@ def upload(src, requirements=False, local_package=None):
155155 upload_s3 (cfg , path_to_zip_file )
156156
157157
158- def invoke (src , alt_event = None , verbose = False ):
158+ def invoke (src , event_file = 'event.json' , config_file = 'config.yaml' , verbose = False ):
159159 """Simulates a call to your function.
160160
161161 :param str src:
@@ -167,7 +167,7 @@ def invoke(src, alt_event=None, verbose=False):
167167 Whether to print out verbose details.
168168 """
169169 # Load and parse the config file.
170- path_to_config_file = os .path .join (src , 'config.yaml' )
170+ path_to_config_file = os .path .join (src , config_file )
171171 cfg = read (path_to_config_file , loader = yaml .load )
172172
173173 # Load environment variables from the config file into the actual
@@ -178,10 +178,7 @@ def invoke(src, alt_event=None, verbose=False):
178178 os .environ [key ] = value
179179
180180 # Load and parse event file.
181- if alt_event :
182- path_to_event_file = os .path .join (src , alt_event )
183- else :
184- path_to_event_file = os .path .join (src , 'event.json' )
181+ path_to_event_file = os .path .join (src , event_file )
185182 event = read (path_to_event_file , loader = json .loads )
186183
187184 # Tweak to allow module to import local modules
@@ -229,7 +226,7 @@ def init(src, minimal=False):
229226 copy (dest_path , src )
230227
231228
232- def build (src , requirements = False , local_package = None ):
229+ def build (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
233230 """Builds the file bundle.
234231
235232 :param str src:
@@ -240,7 +237,7 @@ def build(src, requirements=False, local_package=None):
240237 well (and/or is not available on PyPi)
241238 """
242239 # Load and parse the config file.
243- path_to_config_file = os .path .join (src , 'config.yaml' )
240+ path_to_config_file = os .path .join (src , config_file )
244241 cfg = read (path_to_config_file , loader = yaml .load )
245242
246243 # Get the absolute path to the output directory and create it if it doesn't
@@ -296,7 +293,7 @@ def build(src, requirements=False, local_package=None):
296293 if os .path .isfile (filename ):
297294 if filename == '.DS_Store' :
298295 continue
299- if filename == 'config.yaml' :
296+ if filename == config_file :
300297 continue
301298 print ('Bundling: %r' % filename )
302299 files .append (os .path .join (src , filename ))
0 commit comments