Skip to content

Commit

Permalink
Always call update_function_configuration
Browse files Browse the repository at this point in the history
Handle the case where a user completely removes the env vars
from their config.json.  We'll need this as more config options
for lambda are added.
  • Loading branch information
jamesls committed Apr 3, 2017
1 parent 7e23454 commit ac40465
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions chalice/awsclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ def update_function(self, function_name, zip_contents,
lambda_client = self._client('lambda')
return_value = lambda_client.update_function_code(
FunctionName=function_name, ZipFile=zip_contents)
if environment_variables is not None:
lambda_client.update_function_configuration(
FunctionName=function_name,
Environment={"Variables": environment_variables})
if environment_variables is None:
environment_variables = {}
# We need to handle the case where the user removes
# all env vars from their config.json file. We'll
# just call update_function_configuration every time.
# We're going to need this moving forward anyways,
# more config options besides env vars will be added.
lambda_client.update_function_configuration(
FunctionName=function_name,
Environment={"Variables": environment_variables})
return return_value

def get_role_arn_for_name(self, name):
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_awsclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ def test_deploy_rest_api(stubbed_session):


def test_update_function_code_only(stubbed_session):
stubbed_session.stub('lambda').update_function_code(
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns({})
lambda_client.update_function_configuration(
FunctionName='name', Environment={'Variables': {}}).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo')
Expand Down

0 comments on commit ac40465

Please sign in to comment.