cloud-foundry 0.2.1__tar.gz → 0.2.4__tar.gz
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.
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/PKG-INFO +1 -1
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/__init__.py +2 -1
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/idle_reaper.py +71 -3
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/queue.py +29 -4
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/topic.py +29 -4
- cloud_foundry-0.2.4/cloud_foundry/utils/idle_reaper_client.py +63 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/.gitignore +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/LICENSE +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/README.md +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/archive_builder.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/mail_publisher.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/__init__.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/api_waf.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn_api_origin.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn_site_origin.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/connection_store.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/custom_domain.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/document_repository.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/domain.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/function.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/publisher.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/python_function.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/rest_api.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/site_bucket.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/ui_publisher.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/websocket_api.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/websocket_function.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/python_archive_builder.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/services/authorization_api/security_lambda.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/services/mail_publisher.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/aws_openapi_editor.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/hash_comparator.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/logger.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/names.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/openapi_editor.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/cloud_foundry/utils/websocket_utils.py +0 -0
- {cloud_foundry-0.2.1 → cloud_foundry-0.2.4}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloud-foundry
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: cloud-foundry is a curated set of cloud components that can be used to assemble cloud-based applications.
|
|
5
5
|
Project-URL: Documentation, https://github.com/DanRepik/cloud-foundry
|
|
6
6
|
Project-URL: Source, https://github.com/DanRepik/cloud-foundry
|
|
@@ -22,8 +22,9 @@ from cloud_foundry.pulumi.domain import domain # noqa: F401
|
|
|
22
22
|
from cloud_foundry.pulumi.queue import queue # noqa: F401
|
|
23
23
|
from cloud_foundry.pulumi.topic import topic # noqa: F401
|
|
24
24
|
from cloud_foundry.pulumi.idle_reaper import attach_idle_reaper # noqa: F401
|
|
25
|
+
from cloud_foundry.utils.idle_reaper_client import request_mapping_enable # noqa: F401
|
|
25
26
|
|
|
26
27
|
from cloud_foundry.utils.names import resource_id # noqa: F401
|
|
27
28
|
from cloud_foundry.utils.names import project_slug # noqa: F401
|
|
28
29
|
|
|
29
|
-
version = "0.2.
|
|
30
|
+
version = "0.2.4"
|
|
@@ -4,8 +4,21 @@ civarai-evidence/infra/shared-foundation). Queue owners call
|
|
|
4
4
|
`attach_idle_reaper` after subscribing their Lambda to their queue so the
|
|
5
5
|
reaper auto-disables the event source mapping once the queue is fully
|
|
6
6
|
drained -- avoiding empty-poll SQS request volume from a mapping nobody
|
|
7
|
-
remembered to turn off.
|
|
8
|
-
|
|
7
|
+
remembered to turn off.
|
|
8
|
+
|
|
9
|
+
Re-enabling is still each producer's own responsibility -- the reaper never
|
|
10
|
+
does it on its own initiative -- but `attach_idle_reaper` now also wires an
|
|
11
|
+
on-demand path for that: a second EventRule, scoped to this consumer's
|
|
12
|
+
queue, that matches a custom "EnableMapping" event and re-enables the
|
|
13
|
+
mapping unconditionally (no drain/depth check needed for that direction).
|
|
14
|
+
Producers trigger it via `cloud_foundry.utils.idle_reaper_client.
|
|
15
|
+
request_mapping_enable(queue_url)` -- see that module's docstring for the
|
|
16
|
+
tradeoff between importing it from `cloud_foundry` (pulls in pulumi/
|
|
17
|
+
pulumi-aws transitively, same as any other cloud_foundry import) versus
|
|
18
|
+
inlining its few lines directly in a dependency-sensitive Lambda. Producers
|
|
19
|
+
only ever need the queue URL they already have to know to call SendMessage
|
|
20
|
+
in the first place; they never need the event source mapping's UUID or the
|
|
21
|
+
reaper's function/role names.
|
|
9
22
|
|
|
10
23
|
The reaper's function name and IAM role name are computed deterministically
|
|
11
24
|
via cloud_foundry's own naming convention (see
|
|
@@ -48,9 +61,11 @@ def attach_idle_reaper(
|
|
|
48
61
|
reaper_role_name: str,
|
|
49
62
|
resource_prefix: str,
|
|
50
63
|
interval_minutes: int = 10,
|
|
64
|
+
event_bus_name: str = "default",
|
|
51
65
|
opts: Optional[ResourceOptions] = None,
|
|
52
66
|
) -> None:
|
|
53
|
-
"""Schedule the shared idle-esm-reaper Lambda against one queue/mapping
|
|
67
|
+
"""Schedule the shared idle-esm-reaper Lambda against one queue/mapping,
|
|
68
|
+
and wire an on-demand re-enable path for the same mapping.
|
|
54
69
|
|
|
55
70
|
Args:
|
|
56
71
|
queue: The cloud_foundry Queue (or anything exposing `.arn`/`.url`)
|
|
@@ -65,6 +80,11 @@ def attach_idle_reaper(
|
|
|
65
80
|
resource_prefix: Unique prefix for this consumer's Pulumi resource
|
|
66
81
|
names, e.g. `resource_id("workflow")`.
|
|
67
82
|
interval_minutes: How often the reaper checks this queue.
|
|
83
|
+
event_bus_name: EventBridge bus the on-demand enable rule listens
|
|
84
|
+
on. Must match the bus `idle_reaper_client.request_mapping_enable`
|
|
85
|
+
callers publish to -- both default to the account's "default"
|
|
86
|
+
bus, so this only needs to change if a consumer already uses a
|
|
87
|
+
dedicated custom bus.
|
|
68
88
|
opts: Pulumi ResourceOptions (e.g. `parent=`) applied to every
|
|
69
89
|
resource created here.
|
|
70
90
|
"""
|
|
@@ -138,3 +158,51 @@ def attach_idle_reaper(
|
|
|
138
158
|
source_arn=rule.arn,
|
|
139
159
|
opts=opts,
|
|
140
160
|
)
|
|
161
|
+
|
|
162
|
+
# On-demand enable path. Scoped to this consumer's own queue URL, so a
|
|
163
|
+
# request_mapping_enable() call from any producer only ever wakes the
|
|
164
|
+
# one EventRule whose queue_url it matches -- unmatched events are
|
|
165
|
+
# dropped by EventBridge, no coordination needed across consumers.
|
|
166
|
+
enable_rule = aws.cloudwatch.EventRule(
|
|
167
|
+
f"{resource_prefix}-idle-reaper-enable",
|
|
168
|
+
name=_aws_name(resource_prefix, "idle-reaper-enable", 64),
|
|
169
|
+
event_bus_name=event_bus_name,
|
|
170
|
+
event_pattern=queue.url.apply(
|
|
171
|
+
lambda queue_url: json.dumps(
|
|
172
|
+
{
|
|
173
|
+
"source": ["cloud_foundry.idle_reaper"],
|
|
174
|
+
"detail-type": ["EnableMapping"],
|
|
175
|
+
"detail": {"queue_url": [queue_url]},
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
),
|
|
179
|
+
opts=opts,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
aws.cloudwatch.EventTarget(
|
|
183
|
+
f"{resource_prefix}-idle-reaper-enable-target",
|
|
184
|
+
target_id=_aws_name(resource_prefix, "idle-reaper-enable-tgt", 64),
|
|
185
|
+
rule=enable_rule.name,
|
|
186
|
+
event_bus_name=event_bus_name,
|
|
187
|
+
arn=reaper_arn,
|
|
188
|
+
input=event_source_mapping.id.apply(
|
|
189
|
+
lambda uuid: json.dumps(
|
|
190
|
+
{
|
|
191
|
+
"action": "enable",
|
|
192
|
+
"queue_name": resource_prefix,
|
|
193
|
+
"event_source_mapping_uuid": uuid,
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
),
|
|
197
|
+
opts=opts,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
aws.lambda_.Permission(
|
|
201
|
+
f"{resource_prefix}-idle-reaper-enable-invoke",
|
|
202
|
+
statement_id=_aws_name(resource_prefix, "idle-reaper-enable-invoke", 100),
|
|
203
|
+
action="lambda:InvokeFunction",
|
|
204
|
+
function=reaper_function_name,
|
|
205
|
+
principal="events.amazonaws.com",
|
|
206
|
+
source_arn=enable_rule.arn,
|
|
207
|
+
opts=opts,
|
|
208
|
+
)
|
|
@@ -39,9 +39,15 @@ class QueueArgs:
|
|
|
39
39
|
self,
|
|
40
40
|
visibility_timeout: Optional[int] = None,
|
|
41
41
|
message_retention: Optional[int] = None,
|
|
42
|
+
receive_wait_time: Optional[int] = None,
|
|
43
|
+
tags: Optional[dict[str, str]] = None,
|
|
42
44
|
) -> None:
|
|
43
45
|
self.visibility_timeout = visibility_timeout or 300 # 5 minutes
|
|
44
46
|
self.message_retention = message_retention or 345600 # 4 days
|
|
47
|
+
# 0 (short polling) matches SQS's own default, so leaving this
|
|
48
|
+
# unset is a no-op for existing callers.
|
|
49
|
+
self.receive_wait_time = receive_wait_time or 0
|
|
50
|
+
self.tags = tags or {}
|
|
45
51
|
|
|
46
52
|
|
|
47
53
|
class Queue(ComponentResource):
|
|
@@ -83,10 +89,12 @@ class Queue(ComponentResource):
|
|
|
83
89
|
self.name = name
|
|
84
90
|
"""Create SQS queue with DLQ."""
|
|
85
91
|
# Dead letter queue
|
|
92
|
+
dlq_name = f"{resource_id(self.name)}-dlq"
|
|
86
93
|
self.dlq = aws.sqs.Queue(
|
|
87
94
|
f"{name}-dlq",
|
|
88
|
-
name=
|
|
95
|
+
name=dlq_name,
|
|
89
96
|
message_retention_seconds=1209600, # 14 days
|
|
97
|
+
tags={"Name": dlq_name, **args.tags},
|
|
90
98
|
opts=ResourceOptions(
|
|
91
99
|
parent=self,
|
|
92
100
|
ignore_changes=["region", "tagsAll"],
|
|
@@ -94,11 +102,13 @@ class Queue(ComponentResource):
|
|
|
94
102
|
)
|
|
95
103
|
|
|
96
104
|
# Main queue
|
|
105
|
+
queue_name = resource_id(self.name)
|
|
97
106
|
self.queue = aws.sqs.Queue(
|
|
98
107
|
name,
|
|
99
|
-
name=
|
|
108
|
+
name=queue_name,
|
|
100
109
|
visibility_timeout_seconds=args.visibility_timeout,
|
|
101
110
|
message_retention_seconds=args.message_retention,
|
|
111
|
+
receive_wait_time_seconds=args.receive_wait_time,
|
|
102
112
|
redrive_policy=self.dlq.arn.apply(
|
|
103
113
|
lambda arn: json.dumps(
|
|
104
114
|
{
|
|
@@ -107,6 +117,7 @@ class Queue(ComponentResource):
|
|
|
107
117
|
}
|
|
108
118
|
)
|
|
109
119
|
),
|
|
120
|
+
tags={"Name": queue_name, **args.tags},
|
|
110
121
|
opts=ResourceOptions(
|
|
111
122
|
parent=self,
|
|
112
123
|
ignore_changes=["region", "tagsAll"],
|
|
@@ -195,6 +206,8 @@ def queue(
|
|
|
195
206
|
name: str,
|
|
196
207
|
visibility_timeout: Optional[int] = None,
|
|
197
208
|
message_retention: Optional[int] = None,
|
|
209
|
+
receive_wait_time: Optional[int] = None,
|
|
210
|
+
tags: Optional[dict[str, str]] = None,
|
|
198
211
|
opts: ResourceOptions = None,
|
|
199
212
|
) -> Queue:
|
|
200
213
|
"""Factory function to create a Queue component.
|
|
@@ -204,6 +217,13 @@ def queue(
|
|
|
204
217
|
Defaults to None (300 seconds).
|
|
205
218
|
message_retention (Optional[int]): Message retention period in
|
|
206
219
|
seconds. Defaults to None (345600 seconds).
|
|
220
|
+
receive_wait_time (Optional[int]): Long-polling wait time in
|
|
221
|
+
seconds for ReceiveMessage calls. Defaults to None (0, i.e.
|
|
222
|
+
short polling -- SQS's own default).
|
|
223
|
+
tags (Optional[dict[str, str]]): Extra tags applied to both the
|
|
224
|
+
main queue and its DLQ, alongside the "Name" tag each already
|
|
225
|
+
gets set to its own resource_id()-generated name. A "Name" key
|
|
226
|
+
here overrides that default.
|
|
207
227
|
opts (ResourceOptions, optional): Pulumi resource options.
|
|
208
228
|
Defaults to None.
|
|
209
229
|
Returns:
|
|
@@ -212,13 +232,18 @@ def queue(
|
|
|
212
232
|
>>> my_queue = queue(
|
|
213
233
|
... name="my-message-queue",
|
|
214
234
|
... visibility_timeout=300,
|
|
215
|
-
... message_retention=345600
|
|
235
|
+
... message_retention=345600,
|
|
236
|
+
... receive_wait_time=20,
|
|
237
|
+
... tags={"Environment": "prod"},
|
|
216
238
|
... )
|
|
217
239
|
"""
|
|
218
240
|
return Queue(
|
|
219
241
|
name,
|
|
220
242
|
QueueArgs(
|
|
221
|
-
visibility_timeout=visibility_timeout,
|
|
243
|
+
visibility_timeout=visibility_timeout,
|
|
244
|
+
message_retention=message_retention,
|
|
245
|
+
receive_wait_time=receive_wait_time,
|
|
246
|
+
tags=tags,
|
|
222
247
|
),
|
|
223
248
|
opts,
|
|
224
249
|
)
|
|
@@ -12,10 +12,14 @@ class TopicArgs:
|
|
|
12
12
|
"""Arguments for Topic component."""
|
|
13
13
|
|
|
14
14
|
def __init__(
|
|
15
|
-
self,
|
|
15
|
+
self,
|
|
16
|
+
display_name: Optional[str],
|
|
17
|
+
subscriptions: Optional[list[dict]] = None,
|
|
18
|
+
tags: Optional[dict[str, str]] = None,
|
|
16
19
|
):
|
|
17
20
|
self.display_name = display_name
|
|
18
21
|
self.subscriptions = subscriptions
|
|
22
|
+
self.tags = tags or {}
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
class Topic(ComponentResource):
|
|
@@ -44,10 +48,12 @@ class Topic(ComponentResource):
|
|
|
44
48
|
super().__init__("cloud_foundry:topic:Topic", name, {}, opts)
|
|
45
49
|
|
|
46
50
|
self.name = name
|
|
51
|
+
topic_name = resource_id(name)
|
|
47
52
|
self.topic = aws.sns.Topic(
|
|
48
53
|
name,
|
|
49
|
-
name=
|
|
54
|
+
name=topic_name,
|
|
50
55
|
display_name=args.display_name or name,
|
|
56
|
+
tags={"Name": topic_name, **args.tags},
|
|
51
57
|
opts=ResourceOptions(parent=self),
|
|
52
58
|
)
|
|
53
59
|
|
|
@@ -69,6 +75,17 @@ class Topic(ComponentResource):
|
|
|
69
75
|
"""Get the ARN of the SNS topic."""
|
|
70
76
|
return self.topic.arn
|
|
71
77
|
|
|
78
|
+
@property
|
|
79
|
+
def topic_name(self) -> Output[str]:
|
|
80
|
+
"""Get the deployed AWS name of the SNS topic.
|
|
81
|
+
|
|
82
|
+
Named `topic_name` rather than `name` because `self.name` already
|
|
83
|
+
holds the logical component name (a plain str, used internally for
|
|
84
|
+
default display_name and subscription resource naming) -- reusing
|
|
85
|
+
`name` for this would shadow that with an Output[str] and break it.
|
|
86
|
+
"""
|
|
87
|
+
return self.topic.name
|
|
88
|
+
|
|
72
89
|
def subscribe(self, queue: Queue, opts: ResourceOptions = None) -> None:
|
|
73
90
|
"""Subscribe an SQS queue to this SNS topic.
|
|
74
91
|
Args:
|
|
@@ -121,6 +138,7 @@ def topic(
|
|
|
121
138
|
name: str,
|
|
122
139
|
display_name: Optional[str] = None,
|
|
123
140
|
subscriptions: Optional[list[dict]] = None,
|
|
141
|
+
tags: Optional[dict[str, str]] = None,
|
|
124
142
|
opts: ResourceOptions = None,
|
|
125
143
|
) -> Topic:
|
|
126
144
|
"""Factory function to create a Topic component.
|
|
@@ -131,6 +149,10 @@ def topic(
|
|
|
131
149
|
subscriptions (Optional[list[dict]]): List of subscription configs.
|
|
132
150
|
Each config should be a dict with a 'queue' key for SQS queues.
|
|
133
151
|
Defaults to None.
|
|
152
|
+
tags (Optional[dict[str, str]]): Extra tags applied to the topic,
|
|
153
|
+
alongside the "Name" tag it already gets set to its own
|
|
154
|
+
resource_id()-generated name. A "Name" key here overrides
|
|
155
|
+
that default.
|
|
134
156
|
opts (ResourceOptions, optional): Pulumi resource options.
|
|
135
157
|
Defaults to None.
|
|
136
158
|
Returns:
|
|
@@ -139,9 +161,12 @@ def topic(
|
|
|
139
161
|
>>> my_topic = topic(
|
|
140
162
|
... name="my-topic",
|
|
141
163
|
... display_name="My Topic",
|
|
142
|
-
... subscriptions=[{"queue": my_queue}]
|
|
164
|
+
... subscriptions=[{"queue": my_queue}],
|
|
165
|
+
... tags={"Environment": "prod"},
|
|
143
166
|
... )
|
|
144
167
|
"""
|
|
145
168
|
return Topic(
|
|
146
|
-
name,
|
|
169
|
+
name,
|
|
170
|
+
TopicArgs(display_name=display_name, subscriptions=subscriptions, tags=tags),
|
|
171
|
+
opts,
|
|
147
172
|
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Runtime-side client for cloud_foundry's idle-ESM-reaper "enable" event.
|
|
2
|
+
|
|
3
|
+
Companion to cloud_foundry.pulumi.idle_reaper.attach_idle_reaper -- unlike
|
|
4
|
+
that module (which authors Pulumi infrastructure at `pulumi up` time), this
|
|
5
|
+
one runs inside whatever already-deployed producer/ingestion code sends
|
|
6
|
+
messages into a reaper-managed queue. This module itself only needs boto3,
|
|
7
|
+
but importing it as `cloud_foundry.utils.idle_reaper_client` still runs
|
|
8
|
+
`cloud_foundry/__init__.py` first (normal Python package behavior), which
|
|
9
|
+
pulls in pulumi/pulumi-aws as transitive dependencies of the `cloud-foundry`
|
|
10
|
+
package regardless. A producer that wants to avoid carrying those into a
|
|
11
|
+
lightweight Lambda can inline the few lines of `request_mapping_enable`
|
|
12
|
+
below instead of depending on `cloud-foundry` for just this.
|
|
13
|
+
|
|
14
|
+
A producer that wants the shared reaper to keep its queue's mapping alive
|
|
15
|
+
calls `request_mapping_enable(queue_url)` before sending. It never needs to
|
|
16
|
+
know the event source mapping's UUID, the reaper's function/role names, or
|
|
17
|
+
any Pulumi-side resource naming scheme -- only the queue URL it already has
|
|
18
|
+
to know to call SendMessage in the first place.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import json
|
|
22
|
+
from typing import Optional
|
|
23
|
+
|
|
24
|
+
import boto3
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def request_mapping_enable(
|
|
28
|
+
queue_url: str,
|
|
29
|
+
*,
|
|
30
|
+
event_bus_name: str = "default",
|
|
31
|
+
region_name: Optional[str] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Ask the shared idle-ESM-reaper to re-enable the mapping for `queue_url`.
|
|
34
|
+
|
|
35
|
+
Fire-and-forget: puts a custom event on the given EventBridge bus. Any
|
|
36
|
+
`attach_idle_reaper` consumer whose queue matches `queue_url` picks it
|
|
37
|
+
up via its own scoped EventRule and re-enables its own mapping --
|
|
38
|
+
nothing here needs to know which consumer that is, or whether one
|
|
39
|
+
exists at all (an unmatched event is simply dropped by EventBridge, so
|
|
40
|
+
calling this for a queue that isn't reaper-managed is a harmless no-op).
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
queue_url: The SQS queue URL the caller is about to send messages
|
|
44
|
+
to -- must match the `queue_url` the mapping owner's
|
|
45
|
+
`attach_idle_reaper()` call was scoped to.
|
|
46
|
+
event_bus_name: EventBridge bus to publish to. Must match the
|
|
47
|
+
`event_bus_name` the mapping owner passed to
|
|
48
|
+
`attach_idle_reaper()` -- both default to the account's
|
|
49
|
+
"default" bus.
|
|
50
|
+
region_name: AWS region for the EventBridge client, if not picked
|
|
51
|
+
up from the caller's ambient environment/credentials.
|
|
52
|
+
"""
|
|
53
|
+
events = boto3.client("events", region_name=region_name)
|
|
54
|
+
events.put_events(
|
|
55
|
+
Entries=[
|
|
56
|
+
{
|
|
57
|
+
"EventBusName": event_bus_name,
|
|
58
|
+
"Source": "cloud_foundry.idle_reaper",
|
|
59
|
+
"DetailType": "EnableMapping",
|
|
60
|
+
"Detail": json.dumps({"queue_url": queue_url}),
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|