Repository: localstack/localstack

Issue:
S3 Presigned URL not Triggering Lambda Function
Hello all,

I have noticed that when I generate a presigned url for a file that will be uploaded to S3 that the Lambda function does not get triggered. It seems to only be happening for presigned url. I was able to successful have it trigger when I use the command line and upload a file through `aws s3 cp`. 

To recreate:
1: have any lambda function be added to an s3 bucket. My lambda configurations look as followed:
```
aws s3api --endpoint-url=http://localstack:4572 create-bucket --bucket mybucket;
aws s3api --endpoint-url=http://localstack:4572 create-bucket --bucket code;
aws s3 cp --endpoint-url=http://localstack:4572 --acl public-read /resources/example.zip s3://code/;
aws lambda create-function --endpoint-url=http://localstack:4574 --function-name MyLambdaFunction--runtime 'nodejs8.10' --handler 'index.handler' --role 'anyRole' --code S3Bucket=code,S3Key=example.zip,S3ObjectVersion=1.0.0;
```
Then add this lambda configuration to the bucket
```
{
    "LambdaFunctionConfigurations": [
        {
            "LambdaFunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:MyLambdaFunction",
            "Events": [
                "s3:ObjectCreated:*"
            ]
        }
    ]
}
```
by running
```
aws s3api --endpoint-url=http://localstack:4572 put-bucket-notification-configuration --bucket 'mybucket' --notification-configuration file:///resources/notification.json;
```
2: Generate a presigned url for the bucket you added the lambda too

```
aws s3 presign --endpoint-url=http://localstack:4572 s3://mybucket/test.txt  --expires-in 300
```
3:
```
 curl --upload-file test.txt -v http://localstack:4572/mybucket/test.txt?AWSAccess
KeyId=dummyaccess&Expires=1571680684&Signature=TbCFh1rzkNYwNEooaQKcJPF4%2Fss%3D
```

Lambda does not seem to get triggered.

Any help or fixes?

Thank you so much for your time and help. Localstack has been a great tool!


Discussion:

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
@@ -717,8 +717,9 @@ def is_query_allowable(method, query):
         if not query:
             return True
         # Except we do want to notify on multipart and presigned url upload completion
-        elif (method == 'POST' and query.startswith('uploadId')) or \
-                ('X-Amz-Credential' in query and 'X-Amz-Signature' in query):
+        contains_cred = 'X-Amz-Credential' in query and 'X-Amz-Signature' in query
+        contains_key = 'AWSAccessKeyId' in query and 'Signature' in query
+        if (method == 'POST' and query.startswith('uploadId')) or contains_cred or contains_key:
             return True
 
 
diff --git a/localstack/utils/bootstrap.py b/localstack/utils/bootstrap.py
--- a/localstack/utils/bootstrap.py
+++ b/localstack/utils/bootstrap.py
@@ -107,7 +107,8 @@ def load_plugin_from_path(file_path, scope=None):
             exec('from %s.plugins import %s' % (module, method_name), namespace)
             method_to_execute = namespace[method_name]
         except Exception as e:
-            if not re.match(r'.*cannot import name .*%s.*' % method_name, str(e)):
+            if (not re.match(r'.*cannot import name .*%s.*' % method_name, str(e)) and
+                    ('No module named' not in str(e))):
                 LOG.debug('Unable to load plugins from module %s: %s' % (module, e))
             return
         try:


Test patch: