Repository: localstack/localstack

Issue:
bug: SNS fanout to SQS, different message attributes behavior
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Localstack always bypasses SNS message attributes to SQS message attributes, while AWS does it only when `raw_message_delivery` is enabled. See https://stackoverflow.com/questions/44238656/how-to-add-sqs-message-attributes-in-sns-subscription

### Expected Behavior

SNS message attributes bypassed to SQS message attribute only when `raw_message_delivery` is `true`.

### How are you starting LocalStack?

With a `docker run` command

### Steps To Reproduce

Try to send SNS message with attributes in Localstack and in AWS.
AWS will not map SNS message attributes to SQS message attributes without `raw_message_delivery = true` parameter for a topic subscription.

### Environment

```markdown
- OS: docker
- LocalStack: latest
```


### Anything else?

_No response_


Discussion:

Resolving patch:
diff --git a/localstack/services/sns/sns_listener.py b/localstack/services/sns/sns_listener.py
--- a/localstack/services/sns/sns_listener.py
+++ b/localstack/services/sns/sns_listener.py
@@ -775,9 +775,8 @@ def create_sns_message_body(subscriber, req_data, message_id=None):
 
 
 def create_sqs_message_attributes(subscriber, attributes):
-    # Message attributes are going empty because of this hence removing this check.
-    # if not is_raw_message_delivery(subscriber):
-    #     return {}
+    if not is_raw_message_delivery(subscriber):
+        return {}
 
     message_attributes = {}
     for key, value in attributes.items():


Test patch:
diff --git a/tests/integration/test_sns.py b/tests/integration/test_sns.py
--- a/tests/integration/test_sns.py
+++ b/tests/integration/test_sns.py
@@ -913,14 +913,19 @@ def test_publish_sqs_from_sns(self):
         test_queue = self.sqs_client.create_queue(QueueName="test_queue3")
 
         queue_url = test_queue["QueueUrl"]
-        self.sns_client.subscribe(TopicArn=topic_arn, Protocol="sqs", Endpoint=queue_url)
+        subscription_arn = self.sns_client.subscribe(
+            TopicArn=topic_arn,
+            Protocol="sqs",
+            Endpoint=queue_url,
+            Attributes={"RawMessageDelivery": "true"},
+        )["SubscriptionArn"]
         self.sns_client.publish(
             TargetArn=topic_arn,
             Message="Test msg",
             MessageAttributes={"attr1": {"DataType": "Number", "StringValue": "99.12"}},
         )
 
-        def get_message(queue_url):
+        def get_message_with_attributes(queue_url):
             response = self.sqs_client.receive_message(
                 QueueUrl=queue_url, MessageAttributeNames=["All"]
             )
@@ -928,8 +933,37 @@ def get_message(queue_url):
                 response["Messages"][0]["MessageAttributes"],
                 {"attr1": {"DataType": "Number", "StringValue": "99.12"}},
             )
+            self.sqs_client.delete_message(
+                QueueUrl=queue_url, ReceiptHandle=response["Messages"][0]["ReceiptHandle"]
+            )
+
+        retry(get_message_with_attributes, retries=3, sleep=10, queue_url=queue_url)
+
+        self.sns_client.set_subscription_attributes(
+            SubscriptionArn=subscription_arn,
+            AttributeName="RawMessageDelivery",
+            AttributeValue="false",
+        )
+        self.sns_client.publish(
+            TargetArn=topic_arn,
+            Message="Test msg",
+            MessageAttributes={"attr1": {"DataType": "Number", "StringValue": "100.12"}},
+        )
+
+        def get_message_without_attributes(queue_url):
+            response = self.sqs_client.receive_message(
+                QueueUrl=queue_url, MessageAttributeNames=["All"]
+            )
+            self.assertIsNone(response["Messages"][0].get("MessageAttributes"))
+            self.assertIn(
+                "100.12",
+                response["Messages"][0]["Body"],
+            )
+            self.sqs_client.delete_message(
+                QueueUrl=queue_url, ReceiptHandle=response["Messages"][0]["ReceiptHandle"]
+            )
 
-        retry(get_message, retries=3, sleep=10, queue_url=queue_url)
+        retry(get_message_without_attributes, retries=3, sleep=10, queue_url=queue_url)
 
     def add_xray_header(self, request, **kwargs):
         request.headers[