@@ -294,15 +294,24 @@ def create_function(cfg, path_to_zip_file):
294
294
client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key ,
295
295
cfg .get ('region' ))
296
296
297
+ function_name = os .environ .get ('LAMBDA_FUNCTION_NAME' ) or cfg .get ('function_name' )
298
+ print ('Creating lambda function with name: {}' .format (function_name ))
297
299
client .create_function (
298
- FunctionName = cfg . get ( ' function_name' ) ,
300
+ FunctionName = function_name ,
299
301
Runtime = cfg .get ('runtime' , 'python2.7' ),
300
302
Role = role ,
301
303
Handler = cfg .get ('handler' ),
302
304
Code = {'ZipFile' : byte_stream },
303
305
Description = cfg .get ('description' ),
304
306
Timeout = cfg .get ('timeout' , 15 ),
305
307
MemorySize = cfg .get ('memory_size' , 512 ),
308
+ Environment = {
309
+ 'Variables' : {
310
+ key .strip ('LAMBDA_' ): value
311
+ for key , value in os .environ .items ()
312
+ if key .startswith ('LAMBDA_' )
313
+ }
314
+ },
306
315
Publish = True
307
316
)
308
317
@@ -333,7 +342,11 @@ def update_function(cfg, path_to_zip_file):
333
342
Handler = cfg .get ('handler' ),
334
343
Description = cfg .get ('description' ),
335
344
Timeout = cfg .get ('timeout' , 15 ),
336
- MemorySize = cfg .get ('memory_size' , 512 )
345
+ MemorySize = cfg .get ('memory_size' , 512 ),
346
+ VpcConfig = {
347
+ 'SubnetIds' : cfg .get ('subnet_ids' , []),
348
+ 'SecurityGroupIds' : cfg .get ('security_group_ids' , [])
349
+ }
337
350
)
338
351
339
352
0 commit comments