Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for environment_variables config option #273

Merged
merged 3 commits into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably will want to update the test name now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

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