Repository: localstack/localstack

Issue:
S3 to Lambda notifications throw exception
I can create a “PUT bucket notification configuration” per [this syntax](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putBucketNotificationConfiguration-property):

`awslocal s3api get-bucket-notification-configuration --bucket inbox`:
```json
{
    "LambdaFunctionConfigurations": [
        {
            "Id": "5ea48bb3-78eb-41f1-b4a0-9ed5973ba1dc",
            "LambdaFunctionArn": "arn:aws:lambda:us-west-1:000000000000:function:uploadHandler",
            "Events": [
                "s3:ObjectCreated:*"
            ],
            "Filter": {}
        }
    ]
}
```

Putting an object there does trigger something to happen, but Localstack throws an exception rather than running my Lambda function:

`awslocal s3api put-object --bucket inbox --key test.zip --body ./test.zip`:
```
2017-11-15T01:23:19:ERROR:localstack.services.generic_proxy: Error forwarding request: 'Config' object has no attribute '__getitem__' Traceback (most recent call last):
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 196, in forward
    updated_response = self.proxy.update_listener.return_response(**kwargs)
  File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 493, in return_response
    send_notifications(method, bucket_name, object_path)
  File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 160, in send_notifications
    (bucket_name, config['CloudFunction']))
TypeError: 'Config' object has no attribute '__getitem__'
```


Discussion:
I have s3 notifications working with lambda. The only difference I see with your s3 config and mine is I have set the filter.
Thanks, setting `Filter` to a full object made this error go away. This is still a bug, though, because  `Filter` is not a required field, per the [spec](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putBucketNotificationConfiguration-property). Localstack’s code should handle a configuration without `Filter`.

Also I would think that Localstack should be printing an error message, not just crashing with a stack trace.
Agreed on all points. Localstack is still a new project, I'm confident the kinks will get ironed out in due time.
Actually I take it back: the error/exception goes away when I add a filter _and the put object doesn’t match it._ If I add a filter rule like `{ Name: 'suffix', Value: 'zip' }` and upload a .zip file, I get the crash and stack trace again. In other words, actually trying to run the Lambda is what triggers the exception.

@vangorra Do you mind writing out how exactly you got your version to work? What is your notification configuration? And your Lambda and bucket configurations?

Resolving patch:
diff --git a/localstack/services/s3/s3_listener.py b/localstack/services/s3/s3_listener.py
--- a/localstack/services/s3/s3_listener.py
+++ b/localstack/services/s3/s3_listener.py
@@ -151,8 +151,8 @@ def send_notifications(method, bucket_name, object_path):
                             (bucket_name, config['Topic']))
                 if config.get('CloudFunction'):
                     # make sure we don't run into a socket timeout
-                    config = botocore.config.Config(read_timeout=300)
-                    lambda_client = aws_stack.connect_to_service('lambda', config=config)
+                    connection_config = botocore.config.Config(read_timeout=300)
+                    lambda_client = aws_stack.connect_to_service('lambda', config=connection_config)
                     try:
                         lambda_client.invoke(FunctionName=config['CloudFunction'], Payload=message)
                     except Exception as e:


Test patch: