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