cloud-foundry 0.2.3__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.3 → cloud_foundry-0.2.4}/PKG-INFO +1 -1
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/__init__.py +2 -1
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/idle_reaper.py +71 -3
- cloud_foundry-0.2.4/cloud_foundry/utils/idle_reaper_client.py +63 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/.gitignore +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/LICENSE +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/README.md +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/archive_builder.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/mail_publisher.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/__init__.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/api_waf.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn_api_origin.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/cdn_site_origin.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/connection_store.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/custom_domain.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/document_repository.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/domain.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/function.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/publisher.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/python_function.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/queue.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/rest_api.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/site_bucket.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/topic.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/ui_publisher.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/websocket_api.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/pulumi/websocket_function.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/python_archive_builder.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/services/authorization_api/security_lambda.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/services/mail_publisher.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/aws_openapi_editor.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/hash_comparator.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/logger.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/names.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/openapi_editor.py +0 -0
- {cloud_foundry-0.2.3 → cloud_foundry-0.2.4}/cloud_foundry/utils/websocket_utils.py +0 -0
- {cloud_foundry-0.2.3 → 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
|
+
)
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|