Repository: localstack/localstack

Issue:
SQS to Lambda - the incoming event source ARN does not contain the correct region
## SQS to Lambda - the source_arn does not contain the correct region for the source

An SQS queue and lambda function are provisioned in us-west-2 regiona. An event source mapping exists to enable SQS to Lambda triggers.  When a message arrives in the SQS queue, localstack compares the source_arn for the queue with the ARN in the EventSourceMapping (if they match, then the lambda is invoked).  However, the source ARN for the queue incorrectly contains `us-east-1` region, and so does not match the EventSourceMapping ARN, which correctly contains `us-west-1`

### SQS Queue ARN contains us-west-2:
```
{
    "Attributes": {
        "QueueArn": "arn:aws:sqs:us-west-2:000000000000:local-queue"
    }
}
```

### Lambda function ARN contains us-west-2:
```
{
    "Functions": [
        {
            "FunctionName": "local-lambda",
            "FunctionArn": "arn:aws:lambda:us-west-2:000000000000:function:local-lambda",
        }
    ]
}
```

### EventSourceMapping refers to the correct ARNs:
```
{
    "EventSourceMappings": [
        {
            "EventSourceArn": "arn:aws:sqs:us-west-2:000000000000:local-queue",
            "FunctionArn": "arn:aws:lambda:us-west-2:000000000000:function:local-lambda",
        }
    ]
}
```

### When an SQS message is received in local-queue, the source ARN is incorrect:
```
Found 0 source mappings for event from SQS queue arn:aws:sqs:us-east-1:000000000000:local-queue: []
```

### Additional detail

Sending a message using Java client with region us-west-2, source_arn contains us-east-1

When sending a message using AWS CLI, changing the --region will also change the region in the source_arn.

### Expected behavior
The region in the source_arn should match the region that the resource was created in, OR, the event source mapping should not expect region to match

Relevant for event source mapping: get_event_sources in localstack/services/awslambda/lambda_api.py


Discussion:

Resolving patch:
diff --git a/localstack/services/awslambda/lambda_api.py b/localstack/services/awslambda/lambda_api.py
--- a/localstack/services/awslambda/lambda_api.py
+++ b/localstack/services/awslambda/lambda_api.py
@@ -268,6 +268,7 @@ def process_kinesis_records(records, stream_name):
 def process_sqs_message(message_body, message_attributes, queue_name, region_name=None):
     # feed message into the first listening lambda (message should only get processed once)
     try:
+        region_name = region_name or aws_stack.get_region()
         queue_arn = aws_stack.sqs_queue_arn(queue_name, region_name=region_name)
         sources = get_event_sources(source_arn=queue_arn)
         arns = [s.get('FunctionArn') for s in sources]
diff --git a/localstack/services/sqs/sqs_listener.py b/localstack/services/sqs/sqs_listener.py
--- a/localstack/services/sqs/sqs_listener.py
+++ b/localstack/services/sqs/sqs_listener.py
@@ -8,10 +8,10 @@
 from requests.models import Request, Response
 from localstack import config
 from localstack.config import HOSTNAME_EXTERNAL, SQS_PORT_EXTERNAL
+from localstack.utils.aws import aws_stack
 from localstack.utils.common import to_str, md5, clone
 from localstack.utils.analytics import event_publisher
 from localstack.services.awslambda import lambda_api
-from localstack.utils.aws.aws_stack import extract_region_from_auth_header
 from localstack.services.generic_proxy import ProxyListener
 
 
@@ -86,7 +86,7 @@ def return_response(self, method, path, data, headers, response, request_handler
         if method != 'POST':
             return
 
-        region_name = extract_region_from_auth_header(headers)
+        region_name = aws_stack.get_region()
         req_data = urlparse.parse_qs(to_str(data))
         action = req_data.get('Action', [None])[0]
         content_str = content_str_original = to_str(response.content)
@@ -264,10 +264,9 @@ def _send_message(self, path, data, req_data, headers):
         queue_name = queue_url.rpartition('/')[2]
         message_body = req_data.get('MessageBody', [None])[0]
         message_attributes = self.format_message_attributes(req_data)
-        region_name = extract_region_from_auth_header(headers)
 
         process_result = lambda_api.process_sqs_message(message_body,
-            message_attributes, queue_name, region_name=region_name)
+            message_attributes, queue_name)
         if process_result:
             # If a Lambda was listening, do not add the message to the queue
             new_response = Response()


Test patch: