33
33
log = logging .getLogger (__name__ )
34
34
35
35
36
- def cleanup_old_versions (src , keep_last_versions ):
36
+ def cleanup_old_versions (src , keep_last_versions , config_file = 'config.yaml' ):
37
37
"""Deletes old deployed versions of the function in AWS Lambda.
38
38
39
39
Won't delete $Latest and any aliased version
@@ -47,7 +47,7 @@ def cleanup_old_versions(src, keep_last_versions):
47
47
if keep_last_versions <= 0 :
48
48
print ("Won't delete all versions. Please do this manually" )
49
49
else :
50
- path_to_config_file = os .path .join (src , 'config.yaml' )
50
+ path_to_config_file = os .path .join (src , config_file )
51
51
cfg = read (path_to_config_file , loader = yaml .load )
52
52
53
53
aws_access_key_id = cfg .get ('aws_access_key_id' )
@@ -78,7 +78,7 @@ def cleanup_old_versions(src, keep_last_versions):
78
78
.format (version_number , e .message ))
79
79
80
80
81
- def deploy (src , requirements = False , local_package = None ):
81
+ def deploy (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
82
82
"""Deploys a new function to AWS Lambda.
83
83
84
84
:param str src:
@@ -89,7 +89,7 @@ def deploy(src, requirements=False, local_package=None):
89
89
well (and/or is not available on PyPi)
90
90
"""
91
91
# 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 )
93
93
cfg = read (path_to_config_file , loader = yaml .load )
94
94
95
95
# 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):
104
104
create_function (cfg , path_to_zip_file )
105
105
106
106
107
- def deploy_s3 (src , requirements = False , local_package = None ):
107
+ def deploy_s3 (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
108
108
"""Deploys a new function via AWS S3.
109
109
110
110
:param str src:
@@ -115,7 +115,7 @@ def deploy_s3(src, requirements=False, local_package=None):
115
115
well (and/or is not available on PyPi)
116
116
"""
117
117
# 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 )
119
119
cfg = read (path_to_config_file , loader = yaml .load )
120
120
121
121
# 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):
132
132
create_function (cfg , path_to_zip_file , use_s3 , s3_file )
133
133
134
134
135
- def upload (src , requirements = False , local_package = None ):
135
+ def upload (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
136
136
"""Uploads a new function to AWS S3.
137
137
138
138
:param str src:
@@ -143,7 +143,7 @@ def upload(src, requirements=False, local_package=None):
143
143
well (and/or is not available on PyPi)
144
144
"""
145
145
# 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 )
147
147
cfg = read (path_to_config_file , loader = yaml .load )
148
148
149
149
# 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):
155
155
upload_s3 (cfg , path_to_zip_file )
156
156
157
157
158
- def invoke (src , alt_event = None , verbose = False ):
158
+ def invoke (src , event_file = 'event.json' , config_file = 'config.yaml' , verbose = False ):
159
159
"""Simulates a call to your function.
160
160
161
161
:param str src:
@@ -167,7 +167,7 @@ def invoke(src, alt_event=None, verbose=False):
167
167
Whether to print out verbose details.
168
168
"""
169
169
# 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 )
171
171
cfg = read (path_to_config_file , loader = yaml .load )
172
172
173
173
# Load environment variables from the config file into the actual
@@ -178,10 +178,7 @@ def invoke(src, alt_event=None, verbose=False):
178
178
os .environ [key ] = value
179
179
180
180
# 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 )
185
182
event = read (path_to_event_file , loader = json .loads )
186
183
187
184
# Tweak to allow module to import local modules
@@ -229,7 +226,7 @@ def init(src, minimal=False):
229
226
copy (dest_path , src )
230
227
231
228
232
- def build (src , requirements = False , local_package = None ):
229
+ def build (src , config_file = 'config.yaml' , requirements = False , local_package = None ):
233
230
"""Builds the file bundle.
234
231
235
232
:param str src:
@@ -240,7 +237,7 @@ def build(src, requirements=False, local_package=None):
240
237
well (and/or is not available on PyPi)
241
238
"""
242
239
# 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 )
244
241
cfg = read (path_to_config_file , loader = yaml .load )
245
242
246
243
# 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):
296
293
if os .path .isfile (filename ):
297
294
if filename == '.DS_Store' :
298
295
continue
299
- if filename == 'config.yaml' :
296
+ if filename == config_file :
300
297
continue
301
298
print ('Bundling: %r' % filename )
302
299
files .append (os .path .join (src , filename ))
0 commit comments