lambda: Fix adding environment variables to functions previously not having any
diff --git a/lib/ansible/modules/cloud/amazon/lambda.py b/lib/ansible/modules/cloud/amazon/lambda.py
index 2c5ad38226eec3..0a0a9897b33766 100644
--- a/lib/ansible/modules/cloud/amazon/lambda.py
+++ b/lib/ansible/modules/cloud/amazon/lambda.py
@@ -330,7 +330,7 @@ def main():
             func_kwargs.update({'Timeout': timeout})
         if memory_size and current_config['MemorySize'] != memory_size:
             func_kwargs.update({'MemorySize': memory_size})
-        if (environment_variables is not None) and (current_config['Environment']['Variables'] != environment_variables):
+        if (environment_variables is not None) and (current_config.get('Environment', {}).get('Variables', {}) != environment_variables):
             func_kwargs.update({'Environment':{'Variables': environment_variables}})
         if dead_letter_arn is not None:
             if current_config.get('DeadLetterConfig'):
diff --git a/test/units/modules/cloud/amazon/test_lambda.py b/test/units/modules/cloud/amazon/test_lambda.py
index db718df59f8484..049d1394bc2aad 100644
--- a/test/units/modules/cloud/amazon/test_lambda.py
+++ b/test/units/modules/cloud/amazon/test_lambda.py
@@ -65,6 +65,9 @@ def set_module_args(args):
     "timeout" : 3,
     "handler": 'lambda_python.my_handler'
 }
+module_args_with_environment=dict(base_module_args, environment_variables={
+    "variable_name": "variable_value"
+})
 
 
 def make_mock_no_connection_connection(config):
@@ -206,6 +209,30 @@ def test_update_lambda_if_only_one_config_item_changed():
     assert(len(lambda_client_double.update_function_code.mock_calls) == 0), \
         "updated lambda code when no change should have happened"
 
+def test_update_lambda_if_added_environment_variable():
+
+    set_module_args(module_args_with_environment)
+    (boto3_conn_double,lambda_client_double)=make_mock_connection(base_lambda_config)
+
+    with patch.object(lda, 'boto3_conn', boto3_conn_double):
+        try:
+            lda.main()
+        except SystemExit:
+            pass
+
+    # guard against calling other than for a lambda connection (e.g. IAM)
+    assert(len(boto3_conn_double.mock_calls) == 1), "multiple boto connections used unexpectedly"
+    assert(len(lambda_client_double.update_function_configuration.mock_calls) > 0), \
+        "failed to update lambda function when configuration changed"
+    assert(len(lambda_client_double.update_function_configuration.mock_calls) < 2), \
+        "lambda function update called multiple times when only one time should be needed"
+    assert(len(lambda_client_double.update_function_code.mock_calls) == 0), \
+        "updated lambda code when no change should have happened"
+
+    (update_args, update_kwargs)=lambda_client_double.update_function_configuration.call_args
+    assert (len(update_kwargs) > 0), "expected update configuration called with keyword args, none found"
+    assert update_kwargs['Environment']['Variables'] == module_args_with_environment['environment_variables']
+
 def test_dont_update_lambda_if_nothing_changed():
 
     set_module_args(base_module_args)

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bugfix Pull Request

##### COMPONENT NAME
<!--- Name of the module/plugin/module/task -->
lambda

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.1.0
  config file = /home/mmaslowski/ansible/ansible.cfg
  configured module search path = ['./modules/']
```
with `lambda` module copied from newest `devel`.

##### SUMMARY
<!--- Describe the change, including rationale and design decisions -->

I had an AWS Lambda function created without setting any environment variables (e.g. from the `lambda` module from Ansible 2.2 where it did not support setting them). I changed my playbook to invoke the `lambda` module passing environment variables to the function, now I get:
```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'Environment'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_MXxNLc/ansible_module_lambda.py\", line 510, in <module>\n    main()\n  File \"/tmp/ansible_MXxNLc/ansible_module_lambda.py\", line 333, in main\n    if (environment_variables is not None) and (current_config['Environment']['Variables'] != environment_variables):\nKeyError: 'Environment'\n", "module_stdout": "", "msg": "MODULE FAILURE"}
```
This results from the `Environment` key missing from the config returned by boto3's `get_function`. https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html and linked data types suggest it not being required in the return value.

My commit makes the module consider them empty if they are not returned by the API.

Tested with these versions of boto packages:
```
boto (2.42.0)
boto3 (1.4.4)
botocore (1.5.19)
```

<!---
If you are fixing an existing issue, please include "Fixes #nnn" in your
commit message and your description; but you should still explain what
the change does.
-->

<!-- Paste verbatim command output below, e.g. before and after your change -->