Skip to content

Commit 08705ec

Browse files
committed
Issue: nficano#11, nficano#26 Env Vars
Added environment variable support for update function.
1 parent 1223406 commit 08705ec

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

aws_lambda/aws_lambda.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def create_function(cfg, path_to_zip_file):
365365
'Publish': True
366366
}
367367

368-
if cfg.get('environment_variables', None) is not None:
368+
if 'environment_variables' in cfg:
369369
kwargs.update(
370370
Environment = {
371371
'Variables': {
@@ -398,25 +398,31 @@ def update_function(cfg, path_to_zip_file):
398398
Publish=True
399399
)
400400

401-
client.update_function_configuration(
402-
FunctionName=cfg.get('function_name'),
403-
Role=role,
404-
Handler=cfg.get('handler'),
405-
Description=cfg.get('description'),
406-
Timeout=cfg.get('timeout', 15),
407-
MemorySize=cfg.get('memory_size', 512),
408-
VpcConfig={
401+
kwargs = {
402+
'FunctionName': cfg.get('function_name'),
403+
'Role': role,
404+
'Handler': cfg.get('handler'),
405+
'Description': cfg.get('description'),
406+
'Timeout': cfg.get('timeout', 15),
407+
'MemorySize': cfg.get('memory_size', 512),
408+
'VpcConfig': {
409409
'SubnetIds': cfg.get('subnet_ids', []),
410410
'SecurityGroupIds': cfg.get('security_group_ids', [])
411-
},
412-
Environment={
413-
'Variables': {
414-
key: value
415-
for key, value
416-
in cfg.get('environment_variables').items()
417-
}
418411
}
419-
)
412+
}
413+
414+
if 'environment_variables' in cfg:
415+
kwargs.update(
416+
Environment={
417+
'Variables': {
418+
key: value
419+
for key, value
420+
in cfg.get('environment_variables').items()
421+
}
422+
}
423+
)
424+
425+
client.update_function_configuration(**kwargs)
420426

421427

422428
def function_exists(cfg, function_name):

0 commit comments

Comments
 (0)