@@ -294,15 +294,24 @@ def create_function(cfg, path_to_zip_file):
294294 client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key ,
295295 cfg .get ('region' ))
296296
297+ function_name = os .environ .get ('LAMBDA_FUNCTION_NAME' ) or cfg .get ('function_name' )
298+ print ('Creating lambda function with name: {}' .format (function_name ))
297299 client .create_function (
298- FunctionName = cfg . get ( ' function_name' ) ,
300+ FunctionName = function_name ,
299301 Runtime = cfg .get ('runtime' , 'python2.7' ),
300302 Role = role ,
301303 Handler = cfg .get ('handler' ),
302304 Code = {'ZipFile' : byte_stream },
303305 Description = cfg .get ('description' ),
304306 Timeout = cfg .get ('timeout' , 15 ),
305307 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+ },
306315 Publish = True
307316 )
308317
@@ -333,7 +342,11 @@ def update_function(cfg, path_to_zip_file):
333342 Handler = cfg .get ('handler' ),
334343 Description = cfg .get ('description' ),
335344 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+ }
337350 )
338351
339352
0 commit comments