From 14dd3eb55d3a681e443884e9629ae7c56c38c294 Mon Sep 17 00:00:00 2001 From: Ajay Chinta Date: Wed, 14 Feb 2018 16:19:38 +0530 Subject: [PATCH 1/3] added flag --no-update-config --- aws_lambda/aws_lambda.py | 10 +++++----- scripts/lambda | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/aws_lambda/aws_lambda.py b/aws_lambda/aws_lambda.py index 44f37cc6..aac3c214 100755 --- a/aws_lambda/aws_lambda.py +++ b/aws_lambda/aws_lambda.py @@ -80,7 +80,7 @@ def cleanup_old_versions(src, keep_last_versions, config_file='config.yaml'): def deploy( src, use_requirements=False, local_package=None, - config_file='config.yaml', + config_file='config.yaml', no_update_config=False, ): """Deploys a new function to AWS Lambda. @@ -106,7 +106,7 @@ def deploy( ) if function_exists(cfg, cfg.get('function_name')): - update_function(cfg, path_to_zip_file) + update_function(cfg, path_to_zip_file,no_update_config) else: create_function(cfg, path_to_zip_file) @@ -531,7 +531,7 @@ def create_function(cfg, path_to_zip_file, *use_s3, **s3_file): client.create_function(**kwargs) -def update_function(cfg, path_to_zip_file, *use_s3, **s3_file): +def update_function(cfg, path_to_zip_file,no_update_config=False, *use_s3, **s3_file): """Updates the code of an existing Lambda function""" print('Updating your Lambda function') @@ -595,8 +595,8 @@ def update_function(cfg, path_to_zip_file, *use_s3, **s3_file): }, }, ) - - client.update_function_configuration(**kwargs) + if not no_update_config: + client.update_function_configuration(**kwargs) def upload_s3(cfg, path_to_zip_file, *use_s3): diff --git a/scripts/lambda b/scripts/lambda index 3f3f7ae8..2f0b6573 100755 --- a/scripts/lambda +++ b/scripts/lambda @@ -98,6 +98,12 @@ def invoke(event_file, config_file, verbose): is_flag=True, help='Install all packages defined in requirements.txt', ) +@click.option( + '--no-update-config', + default=False, + is_flag=True, + help='Do not update lambda configuration', +) @click.option( '--local-package', default=None, @@ -105,7 +111,7 @@ def invoke(event_file, config_file, verbose): help='Install local package as well.', multiple=True, ) -def deploy(use_requirements, local_package, config_file): +def deploy(use_requirements, local_package, config_file,no_update_config): aws_lambda.deploy( CURRENT_DIR, config_file=config_file, From 74f33d19c3c3e53bec2862b459afc6c1f050cae4 Mon Sep 17 00:00:00 2001 From: Ajay Chinta Date: Wed, 14 Feb 2018 17:18:32 +0530 Subject: [PATCH 2/3] added logging while config update --- aws_lambda/aws_lambda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aws_lambda/aws_lambda.py b/aws_lambda/aws_lambda.py index aac3c214..af56cef5 100755 --- a/aws_lambda/aws_lambda.py +++ b/aws_lambda/aws_lambda.py @@ -596,7 +596,10 @@ def update_function(cfg, path_to_zip_file,no_update_config=False, *use_s3, **s3_ }, ) if not no_update_config: + print('Updating configuration') client.update_function_configuration(**kwargs) + else: + print('NOT updating configuration') def upload_s3(cfg, path_to_zip_file, *use_s3): From e845f7140c5d3c067ca75b6752e8dc7af45167bf Mon Sep 17 00:00:00 2001 From: Ajay Chinta Date: Wed, 14 Feb 2018 17:22:47 +0530 Subject: [PATCH 3/3] fix id deploy method --- scripts/lambda | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lambda b/scripts/lambda index 2f0b6573..0c7ce310 100755 --- a/scripts/lambda +++ b/scripts/lambda @@ -117,6 +117,7 @@ def deploy(use_requirements, local_package, config_file,no_update_config): config_file=config_file, use_requirements=use_requirements, local_package=local_package, + no_update_config=no_update_config )