localstack-core 4.7.1.dev139__py3-none-any.whl → 4.10.1.dev42__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of localstack-core might be problematic. Click here for more details.

Files changed (208) hide show
  1. localstack/aws/api/acm/__init__.py +122 -122
  2. localstack/aws/api/apigateway/__init__.py +560 -559
  3. localstack/aws/api/cloudcontrol/__init__.py +63 -63
  4. localstack/aws/api/cloudformation/__init__.py +1041 -969
  5. localstack/aws/api/cloudwatch/__init__.py +408 -368
  6. localstack/aws/api/config/__init__.py +788 -786
  7. localstack/aws/api/core.py +4 -0
  8. localstack/aws/api/dynamodb/__init__.py +753 -759
  9. localstack/aws/api/dynamodbstreams/__init__.py +74 -74
  10. localstack/aws/api/ec2/__init__.py +9713 -8573
  11. localstack/aws/api/es/__init__.py +453 -453
  12. localstack/aws/api/events/__init__.py +552 -552
  13. localstack/aws/api/firehose/__init__.py +541 -543
  14. localstack/aws/api/iam/__init__.py +646 -572
  15. localstack/aws/api/kinesis/__init__.py +251 -144
  16. localstack/aws/api/kms/__init__.py +343 -333
  17. localstack/aws/api/lambda_/__init__.py +585 -571
  18. localstack/aws/api/logs/__init__.py +682 -666
  19. localstack/aws/api/opensearch/__init__.py +814 -785
  20. localstack/aws/api/pipes/__init__.py +336 -336
  21. localstack/aws/api/redshift/__init__.py +1192 -1164
  22. localstack/aws/api/resource_groups/__init__.py +175 -175
  23. localstack/aws/api/resourcegroupstaggingapi/__init__.py +67 -67
  24. localstack/aws/api/route53/__init__.py +256 -254
  25. localstack/aws/api/route53resolver/__init__.py +396 -396
  26. localstack/aws/api/s3/__init__.py +1358 -1345
  27. localstack/aws/api/s3control/__init__.py +616 -584
  28. localstack/aws/api/scheduler/__init__.py +118 -118
  29. localstack/aws/api/secretsmanager/__init__.py +193 -193
  30. localstack/aws/api/ses/__init__.py +227 -227
  31. localstack/aws/api/sns/__init__.py +115 -115
  32. localstack/aws/api/sqs/__init__.py +100 -100
  33. localstack/aws/api/ssm/__init__.py +1978 -1970
  34. localstack/aws/api/stepfunctions/__init__.py +323 -323
  35. localstack/aws/api/sts/__init__.py +90 -66
  36. localstack/aws/api/support/__init__.py +112 -112
  37. localstack/aws/api/swf/__init__.py +378 -386
  38. localstack/aws/api/transcribe/__init__.py +425 -425
  39. localstack/aws/client.py +7 -2
  40. localstack/aws/forwarder.py +52 -5
  41. localstack/aws/handlers/analytics.py +1 -1
  42. localstack/aws/handlers/logging.py +12 -2
  43. localstack/aws/handlers/metric_handler.py +41 -1
  44. localstack/aws/handlers/service.py +43 -10
  45. localstack/aws/protocol/parser.py +440 -21
  46. localstack/aws/protocol/serializer.py +684 -64
  47. localstack/aws/protocol/service_router.py +120 -20
  48. localstack/aws/scaffold.py +15 -17
  49. localstack/aws/skeleton.py +4 -2
  50. localstack/aws/spec-patches.json +58 -0
  51. localstack/aws/spec.py +33 -13
  52. localstack/cli/exceptions.py +1 -1
  53. localstack/cli/localstack.py +10 -5
  54. localstack/cli/lpm.py +3 -4
  55. localstack/cli/profiles.py +1 -2
  56. localstack/config.py +18 -12
  57. localstack/constants.py +4 -29
  58. localstack/dev/kubernetes/__main__.py +39 -4
  59. localstack/dev/run/paths.py +1 -1
  60. localstack/dns/plugins.py +5 -1
  61. localstack/dns/server.py +12 -3
  62. localstack/packages/api.py +9 -8
  63. localstack/packages/core.py +2 -2
  64. localstack/packages/plugins.py +0 -8
  65. localstack/runtime/init.py +1 -1
  66. localstack/services/apigateway/helpers.py +5 -9
  67. localstack/services/apigateway/legacy/provider.py +85 -12
  68. localstack/services/apigateway/next_gen/execute_api/integrations/aws.py +3 -0
  69. localstack/services/apigateway/next_gen/execute_api/integrations/http.py +3 -3
  70. localstack/services/apigateway/next_gen/execute_api/test_invoke.py +50 -6
  71. localstack/services/apigateway/next_gen/provider.py +5 -0
  72. localstack/services/apigateway/patches.py +0 -9
  73. localstack/services/cloudformation/engine/entities.py +12 -1
  74. localstack/services/cloudformation/engine/v2/change_set_model.py +0 -3
  75. localstack/services/cloudformation/engine/v2/change_set_model_describer.py +14 -0
  76. localstack/services/cloudformation/engine/v2/change_set_model_executor.py +13 -15
  77. localstack/services/cloudformation/engine/v2/change_set_model_preproc.py +118 -24
  78. localstack/services/cloudformation/engine/v2/change_set_model_transform.py +4 -1
  79. localstack/services/cloudformation/engine/v2/change_set_model_validator.py +5 -14
  80. localstack/services/cloudformation/engine/v2/change_set_model_visitor.py +1 -0
  81. localstack/services/cloudformation/engine/v2/resolving.py +6 -4
  82. localstack/services/cloudformation/engine/yaml_parser.py +9 -2
  83. localstack/services/cloudformation/provider.py +2 -2
  84. localstack/services/cloudformation/resource_provider.py +5 -1
  85. localstack/services/cloudformation/resources.py +24149 -0
  86. localstack/services/cloudformation/v2/entities.py +6 -3
  87. localstack/services/cloudformation/v2/provider.py +178 -33
  88. localstack/services/cloudformation/v2/types.py +8 -4
  89. localstack/services/cloudwatch/provider_v2.py +25 -28
  90. localstack/services/dynamodb/packages.py +2 -1
  91. localstack/services/dynamodb/provider.py +42 -0
  92. localstack/services/dynamodb/v2/provider.py +42 -0
  93. localstack/services/ecr/resource_providers/aws_ecr_repository.py +5 -2
  94. localstack/services/es/provider.py +2 -2
  95. localstack/services/events/event_rule_engine.py +31 -13
  96. localstack/services/events/models.py +4 -5
  97. localstack/services/events/target.py +17 -9
  98. localstack/services/iam/provider.py +11 -116
  99. localstack/services/iam/resources/policy_simulator.py +133 -0
  100. localstack/services/kinesis/models.py +15 -2
  101. localstack/services/kinesis/packages.py +1 -1
  102. localstack/services/kinesis/provider.py +77 -0
  103. localstack/services/kms/models.py +34 -4
  104. localstack/services/kms/provider.py +107 -21
  105. localstack/services/lambda_/api_utils.py +3 -1
  106. localstack/services/lambda_/invocation/internal_sqs_queue.py +5 -9
  107. localstack/services/lambda_/packages.py +1 -1
  108. localstack/services/lambda_/provider.py +1 -1
  109. localstack/services/lambda_/runtimes.py +8 -3
  110. localstack/services/logs/provider.py +36 -19
  111. localstack/services/moto.py +2 -1
  112. localstack/services/opensearch/cluster.py +15 -7
  113. localstack/services/opensearch/packages.py +26 -7
  114. localstack/services/opensearch/provider.py +6 -1
  115. localstack/services/opensearch/versions.py +56 -7
  116. localstack/services/s3/constants.py +5 -2
  117. localstack/services/s3/cors.py +4 -4
  118. localstack/services/s3/notifications.py +1 -1
  119. localstack/services/s3/presigned_url.py +27 -43
  120. localstack/services/s3/provider.py +68 -12
  121. localstack/services/s3/utils.py +42 -11
  122. localstack/services/ses/provider.py +16 -7
  123. localstack/services/sns/constants.py +7 -1
  124. localstack/services/sns/v2/models.py +190 -0
  125. localstack/services/sns/v2/provider.py +992 -2
  126. localstack/services/sns/v2/utils.py +138 -0
  127. localstack/services/sqs/developer_api.py +205 -0
  128. localstack/services/sqs/models.py +79 -13
  129. localstack/services/sqs/provider.py +8 -309
  130. localstack/services/sqs/query_api.py +1 -1
  131. localstack/services/sqs/utils.py +121 -2
  132. localstack/services/stepfunctions/asl/jsonata/jsonata.py +1 -1
  133. localstack/testing/aws/cloudformation_utils.py +1 -1
  134. localstack/testing/pytest/cloudformation/fixtures.py +3 -3
  135. localstack/testing/pytest/container.py +4 -5
  136. localstack/testing/pytest/fixtures.py +20 -19
  137. localstack/testing/pytest/in_memory_localstack.py +0 -4
  138. localstack/testing/pytest/marking.py +13 -4
  139. localstack/testing/pytest/stepfunctions/utils.py +4 -3
  140. localstack/testing/pytest/util.py +1 -1
  141. localstack/testing/pytest/validation_tracking.py +1 -2
  142. localstack/testing/snapshots/transformer_utility.py +7 -0
  143. localstack/testing/testselection/matching.py +0 -1
  144. localstack/utils/analytics/events.py +2 -2
  145. localstack/utils/analytics/metadata.py +1 -2
  146. localstack/utils/analytics/metrics/counter.py +6 -8
  147. localstack/utils/analytics/publisher.py +1 -2
  148. localstack/utils/analytics/service_request_aggregator.py +2 -2
  149. localstack/utils/archives.py +11 -11
  150. localstack/utils/aws/arns.py +17 -9
  151. localstack/utils/aws/aws_responses.py +7 -7
  152. localstack/utils/aws/aws_stack.py +2 -3
  153. localstack/utils/aws/client_types.py +0 -8
  154. localstack/utils/aws/message_forwarding.py +1 -2
  155. localstack/utils/aws/request_context.py +4 -5
  156. localstack/utils/batch_policy.py +3 -3
  157. localstack/utils/bootstrap.py +7 -7
  158. localstack/utils/catalog/catalog.py +139 -0
  159. localstack/utils/catalog/catalog_loader.py +119 -0
  160. localstack/utils/catalog/common.py +58 -0
  161. localstack/utils/catalog/plugins.py +28 -0
  162. localstack/utils/cloudwatch/cloudwatch_util.py +5 -5
  163. localstack/utils/collections.py +7 -8
  164. localstack/utils/config_listener.py +1 -1
  165. localstack/utils/container_networking.py +2 -3
  166. localstack/utils/container_utils/container_client.py +115 -131
  167. localstack/utils/container_utils/docker_cmd_client.py +42 -42
  168. localstack/utils/container_utils/docker_sdk_client.py +63 -62
  169. localstack/utils/crypto.py +109 -0
  170. localstack/utils/diagnose.py +2 -3
  171. localstack/utils/docker_utils.py +3 -4
  172. localstack/utils/files.py +31 -7
  173. localstack/utils/functions.py +3 -2
  174. localstack/utils/http.py +4 -5
  175. localstack/utils/json.py +19 -5
  176. localstack/utils/kinesis/kinesis_connector.py +2 -1
  177. localstack/utils/net.py +6 -6
  178. localstack/utils/no_exit_argument_parser.py +2 -2
  179. localstack/utils/numbers.py +9 -2
  180. localstack/utils/objects.py +6 -5
  181. localstack/utils/patch.py +2 -1
  182. localstack/utils/run.py +10 -9
  183. localstack/utils/scheduler.py +11 -11
  184. localstack/utils/server/tcp_proxy.py +2 -2
  185. localstack/utils/serving.py +2 -3
  186. localstack/utils/strings.py +10 -11
  187. localstack/utils/sync.py +126 -1
  188. localstack/utils/tagging.py +1 -4
  189. localstack/utils/testutil.py +5 -4
  190. localstack/utils/threads.py +2 -2
  191. localstack/utils/time.py +11 -3
  192. localstack/utils/urls.py +1 -3
  193. localstack/version.py +2 -2
  194. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/METADATA +19 -13
  195. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/RECORD +203 -199
  196. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/entry_points.txt +4 -2
  197. localstack_core-4.10.1.dev42.dist-info/plux.json +1 -0
  198. localstack/packages/terraform.py +0 -46
  199. localstack/services/cloudformation/deploy.html +0 -144
  200. localstack/services/cloudformation/deploy_ui.py +0 -47
  201. localstack/services/cloudformation/plugins.py +0 -12
  202. localstack_core-4.7.1.dev139.dist-info/plux.json +0 -1
  203. {localstack_core-4.7.1.dev139.data → localstack_core-4.10.1.dev42.data}/scripts/localstack +0 -0
  204. {localstack_core-4.7.1.dev139.data → localstack_core-4.10.1.dev42.data}/scripts/localstack-supervisor +0 -0
  205. {localstack_core-4.7.1.dev139.data → localstack_core-4.10.1.dev42.data}/scripts/localstack.bat +0 -0
  206. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/WHEEL +0 -0
  207. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/licenses/LICENSE.txt +0 -0
  208. {localstack_core-4.7.1.dev139.dist-info → localstack_core-4.10.1.dev42.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,190 @@
1
+ import itertools
2
+ import time
3
+ from dataclasses import dataclass, field
4
+ from enum import StrEnum
5
+ from typing import Literal, TypedDict
6
+
7
+ from localstack.aws.api.sns import (
8
+ Endpoint,
9
+ MessageAttributeMap,
10
+ PlatformApplication,
11
+ PublishBatchRequestEntry,
12
+ TopicAttributesMap,
13
+ subscriptionARN,
14
+ topicARN,
15
+ )
16
+ from localstack.services.stores import (
17
+ AccountRegionBundle,
18
+ BaseStore,
19
+ CrossRegionAttribute,
20
+ LocalAttribute,
21
+ )
22
+ from localstack.utils.objects import singleton_factory
23
+ from localstack.utils.strings import long_uid
24
+ from localstack.utils.tagging import TaggingService
25
+
26
+
27
+ class Topic(TypedDict, total=True):
28
+ arn: str
29
+ name: str
30
+ attributes: TopicAttributesMap
31
+ subscriptions: list[str]
32
+
33
+
34
+ SnsProtocols = Literal[
35
+ "http", "https", "email", "email-json", "sms", "sqs", "application", "lambda", "firehose"
36
+ ]
37
+
38
+ SnsApplicationPlatforms = Literal[
39
+ "APNS", "APNS_SANDBOX", "ADM", "FCM", "Baidu", "GCM", "MPNS", "WNS"
40
+ ]
41
+
42
+
43
+ class EndpointAttributeNames(StrEnum):
44
+ CUSTOM_USER_DATA = "CustomUserData"
45
+ Token = "Token"
46
+ ENABLED = "Enabled"
47
+
48
+
49
+ SMS_ATTRIBUTE_NAMES = [
50
+ "DeliveryStatusIAMRole",
51
+ "DeliveryStatusSuccessSamplingRate",
52
+ "DefaultSenderID",
53
+ "DefaultSMSType",
54
+ "UsageReportS3Bucket",
55
+ ]
56
+ SMS_TYPES = ["Promotional", "Transactional"]
57
+ SMS_DEFAULT_SENDER_REGEX = r"^(?=[A-Za-z0-9]{1,11}$)(?=.*[A-Za-z])[A-Za-z0-9]+$"
58
+ SnsMessageProtocols = Literal[SnsProtocols, SnsApplicationPlatforms]
59
+
60
+
61
+ class SnsSubscription(TypedDict, total=False):
62
+ """
63
+ In SNS, Subscription can be represented with only TopicArn, Endpoint, Protocol, SubscriptionArn and Owner, for
64
+ example in ListSubscriptions. However, when getting a subscription with GetSubscriptionAttributes, it will return
65
+ the Subscription object merged with its own attributes.
66
+ This represents this merged object, for internal use and in GetSubscriptionAttributes
67
+ https://docs.aws.amazon.com/cli/latest/reference/sns/get-subscription-attributes.html
68
+ """
69
+
70
+ TopicArn: topicARN
71
+ Endpoint: str
72
+ Protocol: SnsProtocols
73
+ SubscriptionArn: subscriptionARN
74
+ PendingConfirmation: Literal["true", "false"]
75
+ Owner: str | None
76
+ SubscriptionPrincipal: str | None
77
+ FilterPolicy: str | None
78
+ FilterPolicyScope: Literal["MessageAttributes", "MessageBody"]
79
+ RawMessageDelivery: Literal["true", "false"]
80
+ ConfirmationWasAuthenticated: Literal["true", "false"]
81
+ SubscriptionRoleArn: str | None
82
+ DeliveryPolicy: str | None
83
+
84
+
85
+ @singleton_factory
86
+ def global_sns_message_sequence():
87
+ # creates a 20-digit number used as the start for the global sequence, adds 100 for it to be different from SQS's
88
+ # mostly for testing purpose, both global sequence would be initialized at the same and be identical
89
+ start = int(time.time() + 100) << 33
90
+ # itertools.count is thread safe over the GIL since its getAndIncrement operation is a single python bytecode op
91
+ return itertools.count(start)
92
+
93
+
94
+ def get_next_sequence_number():
95
+ return next(global_sns_message_sequence())
96
+
97
+
98
+ class SnsMessageType(StrEnum):
99
+ Notification = "Notification"
100
+ SubscriptionConfirmation = "SubscriptionConfirmation"
101
+ UnsubscribeConfirmation = "UnsubscribeConfirmation"
102
+
103
+
104
+ @dataclass
105
+ class SnsMessage:
106
+ type: SnsMessageType
107
+ message: (
108
+ str | dict
109
+ ) # can be Dict if after being JSON decoded for validation if structure is `json`
110
+ message_attributes: MessageAttributeMap | None = None
111
+ message_structure: str | None = None
112
+ subject: str | None = None
113
+ message_deduplication_id: str | None = None
114
+ message_group_id: str | None = None
115
+ token: str | None = None
116
+ message_id: str = field(default_factory=long_uid)
117
+ is_fifo: bool | None = False
118
+ sequencer_number: str | None = None
119
+
120
+ def __post_init__(self):
121
+ if self.message_attributes is None:
122
+ self.message_attributes = {}
123
+ if self.is_fifo:
124
+ self.sequencer_number = str(get_next_sequence_number())
125
+
126
+ def message_content(self, protocol: SnsMessageProtocols) -> str:
127
+ """
128
+ Helper function to retrieve the message content for the right protocol if the StructureMessage is `json`
129
+ See https://docs.aws.amazon.com/sns/latest/dg/sns-send-custom-platform-specific-payloads-mobile-devices.html
130
+ https://docs.aws.amazon.com/sns/latest/dg/example_sns_Publish_section.html
131
+ :param protocol:
132
+ :return: message content as string
133
+ """
134
+ if self.message_structure == "json":
135
+ return self.message.get(protocol, self.message.get("default"))
136
+
137
+ return self.message
138
+
139
+ @classmethod
140
+ def from_batch_entry(cls, entry: PublishBatchRequestEntry, is_fifo=False) -> "SnsMessage":
141
+ return cls(
142
+ type=SnsMessageType.Notification,
143
+ message=entry["Message"],
144
+ subject=entry.get("Subject"),
145
+ message_structure=entry.get("MessageStructure"),
146
+ message_attributes=entry.get("MessageAttributes"),
147
+ message_deduplication_id=entry.get("MessageDeduplicationId"),
148
+ message_group_id=entry.get("MessageGroupId"),
149
+ is_fifo=is_fifo,
150
+ )
151
+
152
+
153
+ @dataclass
154
+ class PlatformEndpoint:
155
+ platform_application_arn: str
156
+ platform_endpoint: Endpoint
157
+
158
+
159
+ @dataclass
160
+ class PlatformApplicationDetails:
161
+ platform_application: PlatformApplication
162
+ # maps all Endpoints of the PlatformApplication, from their Token to their ARN
163
+ platform_endpoints: dict[str, str]
164
+
165
+
166
+ class SnsStore(BaseStore):
167
+ topics: dict[str, Topic] = LocalAttribute(default=dict)
168
+
169
+ # maps subscription ARN to SnsSubscription
170
+ subscriptions: dict[str, SnsSubscription] = LocalAttribute(default=dict)
171
+
172
+ # filter policy are stored as JSON string in subscriptions, store the decoded result Dict
173
+ subscription_filter_policy: dict[subscriptionARN, dict] = LocalAttribute(default=dict)
174
+
175
+ # maps confirmation token to subscription ARN
176
+ subscription_tokens: dict[str, str] = LocalAttribute(default=dict)
177
+
178
+ # maps platform application arns to platform applications
179
+ platform_applications: dict[str, PlatformApplicationDetails] = LocalAttribute(default=dict)
180
+
181
+ # maps endpoint arns to platform endpoints
182
+ platform_endpoints: dict[str, PlatformEndpoint] = LocalAttribute(default=dict)
183
+
184
+ # topic/subscription independent default values for sending sms messages
185
+ sms_attributes: dict[str, str] = LocalAttribute(default=dict)
186
+
187
+ TAGS: TaggingService = CrossRegionAttribute(default=TaggingService)
188
+
189
+
190
+ sns_stores = AccountRegionBundle("sns", SnsStore)