cloud-foundry 0.2.4__tar.gz → 0.3.1__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.4 → cloud_foundry-0.3.1}/PKG-INFO +1 -2
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/__init__.py +1 -1
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/function.py +80 -2
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/python_function.py +3 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/pyproject.toml +18 -2
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/.gitignore +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/LICENSE +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/README.md +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/archive_builder.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/mail_publisher.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/__init__.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/api_waf.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/cdn.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/cdn_api_origin.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/cdn_site_origin.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/connection_store.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/custom_domain.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/document_repository.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/domain.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/idle_reaper.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/publisher.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/queue.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/rest_api.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/site_bucket.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/topic.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/ui_publisher.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/websocket_api.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/pulumi/websocket_function.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/python_archive_builder.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/services/authorization_api/security_lambda.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/services/mail_publisher.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/aws_openapi_editor.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/hash_comparator.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/idle_reaper_client.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/logger.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/names.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/openapi_editor.py +0 -0
- {cloud_foundry-0.2.4 → cloud_foundry-0.3.1}/cloud_foundry/utils/websocket_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloud-foundry
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
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
|
|
@@ -17,7 +17,6 @@ Provides-Extra: dev
|
|
|
17
17
|
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
18
18
|
Requires-Dist: build; extra == 'dev'
|
|
19
19
|
Requires-Dist: docker; extra == 'dev'
|
|
20
|
-
Requires-Dist: fixture-foundry; extra == 'dev'
|
|
21
20
|
Requires-Dist: flake8; extra == 'dev'
|
|
22
21
|
Requires-Dist: flit>=3.9; extra == 'dev'
|
|
23
22
|
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# function.py
|
|
2
|
+
import os
|
|
2
3
|
import platform
|
|
3
4
|
from typing import Any, Optional, TypeAlias, Union
|
|
4
5
|
|
|
@@ -14,6 +15,20 @@ PolicyStatement: TypeAlias = dict[str, Any] | str
|
|
|
14
15
|
PolicyStatements: TypeAlias = list[PolicyStatement]
|
|
15
16
|
PolicyStatementsInput: TypeAlias = pulumi.Input[PolicyStatements]
|
|
16
17
|
|
|
18
|
+
# AWS's documented cap for Lambda's direct/inline code upload (the
|
|
19
|
+
# CreateFunction/UpdateFunctionCode API's request-body limit for a
|
|
20
|
+
# base64-encoded zip passed as `code=`). S3-based upload (code_bucket=)
|
|
21
|
+
# raises this to 250MB unzipped.
|
|
22
|
+
DIRECT_UPLOAD_SIZE_LIMIT = 50 * 1024 * 1024
|
|
23
|
+
|
|
24
|
+
CodeBucketInput = Union[str, pulumi.Output[str], "aws.s3.BucketV2", "aws.s3.Bucket"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _code_bucket_name(bucket: CodeBucketInput) -> pulumi.Input[str]:
|
|
28
|
+
if isinstance(bucket, (aws.s3.BucketV2, aws.s3.Bucket)):
|
|
29
|
+
return bucket.bucket
|
|
30
|
+
return bucket
|
|
31
|
+
|
|
17
32
|
|
|
18
33
|
class Function(pulumi.ComponentResource):
|
|
19
34
|
lambda_: aws.lambda_.Function
|
|
@@ -32,6 +47,7 @@ class Function(pulumi.ComponentResource):
|
|
|
32
47
|
environment: dict[str, Union[str, pulumi.Output[str]]] = None,
|
|
33
48
|
policy_statements: Optional[PolicyStatementsInput] = None,
|
|
34
49
|
vpc_config: Optional[dict] = None,
|
|
50
|
+
code_bucket: Optional[CodeBucketInput] = None,
|
|
35
51
|
opts=None,
|
|
36
52
|
):
|
|
37
53
|
super().__init__("cloud_foundry:lambda:Function", name, {}, opts)
|
|
@@ -47,6 +63,7 @@ class Function(pulumi.ComponentResource):
|
|
|
47
63
|
self.timeout = timeout
|
|
48
64
|
self.policy_statements = policy_statements or []
|
|
49
65
|
self.vpc_config = vpc_config or {}
|
|
66
|
+
self.code_bucket = code_bucket
|
|
50
67
|
self.function_name = f"{pulumi.get_project()}-{pulumi.get_stack()}-{self.name}"
|
|
51
68
|
self.log_group_name = f"/aws/lambda/{self.function_name}"
|
|
52
69
|
# Validate that the environment is a dictionary with string
|
|
@@ -143,9 +160,61 @@ class Function(pulumi.ComponentResource):
|
|
|
143
160
|
|
|
144
161
|
log.info("Environment args type: %s", type(environment_args))
|
|
145
162
|
|
|
163
|
+
code_depends_on = []
|
|
164
|
+
if self.code_bucket is not None:
|
|
165
|
+
# Explicit opt-in: upload via S3 instead of passing the zip
|
|
166
|
+
# inline. Keyed by content hash so unchanged code across
|
|
167
|
+
# deploys reuses the same object instead of re-uploading.
|
|
168
|
+
#
|
|
169
|
+
# hash is required here (unlike the inline path below, which
|
|
170
|
+
# doesn't need it): without a real value, the key degrades to
|
|
171
|
+
# "name/None.zip" -- every version collides on the same S3
|
|
172
|
+
# object, and source_code_hash=None below means Pulumi's own
|
|
173
|
+
# diff sees no change between deploys either, so a later code
|
|
174
|
+
# change wouldn't even trigger a Lambda update.
|
|
175
|
+
if not self.hash:
|
|
176
|
+
raise ValueError(
|
|
177
|
+
f"Function '{self.name}': code_bucket requires hash= "
|
|
178
|
+
f"(used for both the S3 object key and Lambda change "
|
|
179
|
+
f"detection). python_function() always supplies this; "
|
|
180
|
+
f"only the lower-level Function()/function() API can "
|
|
181
|
+
f"omit it."
|
|
182
|
+
)
|
|
183
|
+
bucket_name = _code_bucket_name(self.code_bucket)
|
|
184
|
+
code_object = aws.s3.BucketObjectv2(
|
|
185
|
+
f"{self.name}-code",
|
|
186
|
+
bucket=bucket_name,
|
|
187
|
+
key=f"{self.name}/{self.hash}.zip",
|
|
188
|
+
source=pulumi.FileAsset(self.archive_location),
|
|
189
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
190
|
+
)
|
|
191
|
+
code_args = {"s3_bucket": bucket_name, "s3_key": code_object.key}
|
|
192
|
+
code_depends_on = [code_object]
|
|
193
|
+
else:
|
|
194
|
+
# Pulumi resource creation is async (the actual CreateFunction
|
|
195
|
+
# call happens in the provider plugin during apply, not
|
|
196
|
+
# synchronously here), so AWS's RequestEntityTooLargeException
|
|
197
|
+
# can't be caught with a plain try/except around the resource
|
|
198
|
+
# declaration below -- check the size ourselves first instead,
|
|
199
|
+
# for the same practical effect: a clear error at plan time
|
|
200
|
+
# instead of a cryptic one after an apply attempt.
|
|
201
|
+
archive_size = os.path.getsize(self.archive_location)
|
|
202
|
+
if archive_size > DIRECT_UPLOAD_SIZE_LIMIT:
|
|
203
|
+
raise ValueError(
|
|
204
|
+
f"Lambda deployment package for '{self.name}' is "
|
|
205
|
+
f"{archive_size / (1024 * 1024):.1f}MB, over AWS's "
|
|
206
|
+
f"~50MB limit for direct/inline upload (the "
|
|
207
|
+
f"CreateFunction API's request-body cap). Pass "
|
|
208
|
+
f"code_bucket=<an aws.s3.BucketV2/Bucket or bucket "
|
|
209
|
+
f"name> to python_function()/Function() to upload it "
|
|
210
|
+
f"via S3 instead, which supports packages up to "
|
|
211
|
+
f"250MB unzipped."
|
|
212
|
+
)
|
|
213
|
+
code_args = {"code": pulumi.FileArchive(self.archive_location)}
|
|
214
|
+
|
|
146
215
|
self.lambda_ = aws.lambda_.Function(
|
|
147
216
|
f"{self.name}-function",
|
|
148
|
-
|
|
217
|
+
**code_args,
|
|
149
218
|
name=self.function_name,
|
|
150
219
|
role=execution_role.arn,
|
|
151
220
|
memory_size=self.memory_size,
|
|
@@ -157,7 +226,8 @@ class Function(pulumi.ComponentResource):
|
|
|
157
226
|
environment=environment_args,
|
|
158
227
|
vpc_config=vpc_config_args,
|
|
159
228
|
opts=pulumi.ResourceOptions(
|
|
160
|
-
depends_on=[execution_role, log_group],
|
|
229
|
+
depends_on=[execution_role, log_group] + code_depends_on,
|
|
230
|
+
parent=self,
|
|
161
231
|
),
|
|
162
232
|
)
|
|
163
233
|
|
|
@@ -351,6 +421,7 @@ def function(
|
|
|
351
421
|
environment: dict[str, str] = None,
|
|
352
422
|
policy_statements: list = None,
|
|
353
423
|
vpc_config: dict = None,
|
|
424
|
+
code_bucket: Optional[CodeBucketInput] = None,
|
|
354
425
|
opts=None,
|
|
355
426
|
) -> Function:
|
|
356
427
|
"""
|
|
@@ -370,6 +441,12 @@ def function(
|
|
|
370
441
|
policy_statements (list): IAM policy statements for the
|
|
371
442
|
Lambda function.
|
|
372
443
|
vpc_config (dict): VPC configuration for the Lambda function.
|
|
444
|
+
code_bucket: An aws.s3.BucketV2/Bucket or bucket name to upload the
|
|
445
|
+
code archive through instead of passing it inline. Required if
|
|
446
|
+
the archive exceeds AWS's ~50MB direct-upload limit -- omitting
|
|
447
|
+
it in that case raises a ValueError explaining this parameter,
|
|
448
|
+
rather than letting the deploy fail on AWS's own cryptic
|
|
449
|
+
RequestEntityTooLargeException.
|
|
373
450
|
opts: Pulumi resource options.
|
|
374
451
|
|
|
375
452
|
Returns:
|
|
@@ -386,6 +463,7 @@ def function(
|
|
|
386
463
|
environment=environment,
|
|
387
464
|
policy_statements=policy_statements,
|
|
388
465
|
vpc_config=vpc_config,
|
|
466
|
+
code_bucket=code_bucket,
|
|
389
467
|
opts=opts,
|
|
390
468
|
)
|
|
391
469
|
|
|
@@ -6,6 +6,7 @@ from cloud_foundry.utils.logger import logger
|
|
|
6
6
|
|
|
7
7
|
from cloud_foundry.python_archive_builder import PythonArchiveBuilder
|
|
8
8
|
from cloud_foundry.pulumi.function import (
|
|
9
|
+
CodeBucketInput,
|
|
9
10
|
Function,
|
|
10
11
|
PolicyStatementsInput,
|
|
11
12
|
default_lambda_architecture,
|
|
@@ -27,6 +28,7 @@ def python_function(
|
|
|
27
28
|
vpc_config: Optional[dict] = None,
|
|
28
29
|
runtime: Optional[str] = None,
|
|
29
30
|
architecture: Optional[str] = None,
|
|
31
|
+
code_bucket: Optional[CodeBucketInput] = None,
|
|
30
32
|
opts=None,
|
|
31
33
|
) -> Function:
|
|
32
34
|
resolved_architecture = architecture or default_lambda_architecture()
|
|
@@ -49,5 +51,6 @@ def python_function(
|
|
|
49
51
|
vpc_config=vpc_config,
|
|
50
52
|
runtime=runtime,
|
|
51
53
|
architectures=[resolved_architecture],
|
|
54
|
+
code_bucket=code_bucket,
|
|
52
55
|
opts=opts,
|
|
53
56
|
)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# src/pyproject.toml
|
|
2
2
|
|
|
3
3
|
[build-system]
|
|
4
|
-
|
|
4
|
+
# hatchling>=1.32.0 emits Metadata-Version: 2.5, which PyPI's Warehouse
|
|
5
|
+
# rejects outright with a 400 on every upload regardless of package
|
|
6
|
+
# version -- see https://github.com/pypi/warehouse/issues/19083 (open,
|
|
7
|
+
# unresolved). Pinned below that until Warehouse adds 2.5 support.
|
|
8
|
+
requires = ["hatchling>=1.0,<1.32.0"]
|
|
5
9
|
build-backend = "hatchling.build"
|
|
6
10
|
|
|
7
11
|
[project]
|
|
@@ -45,10 +49,22 @@ dev = [
|
|
|
45
49
|
"requests",
|
|
46
50
|
"python-dotenv",
|
|
47
51
|
"pyjwt",
|
|
48
|
-
"fixture_foundry",
|
|
49
52
|
"psycopg2-binary",
|
|
50
53
|
]
|
|
51
54
|
|
|
55
|
+
# fixture_foundry is NOT listed above on purpose. PyPI's upload API rejects
|
|
56
|
+
# any package whose metadata declares a direct URL/VCS dependency, even one
|
|
57
|
+
# scoped to an optional extra -- so a git-pinned entry here would block
|
|
58
|
+
# every future `cloud-foundry` publish, not just fail quietly. Published
|
|
59
|
+
# fixture_foundry (still 0.2.4 as of this pin) has stale calls into its own
|
|
60
|
+
# context.py API that crash test collection (see DanRepik/fixture_foundry#4,
|
|
61
|
+
# fixed on branch fix/fixtures-stale-teardown-calls but not yet released).
|
|
62
|
+
# Install it separately before running the integration test suite:
|
|
63
|
+
# pip install git+https://github.com/DanRepik/fixture_foundry.git@fix/fixtures-stale-teardown-calls
|
|
64
|
+
# CI does this as its own step -- see .github/workflows/pytest.yml and
|
|
65
|
+
# publish.yml. Once a fixed version is published to PyPI, add a plain
|
|
66
|
+
# "fixture_foundry>=X.Y.Z" back to the dev extra above and drop this note.
|
|
67
|
+
|
|
52
68
|
[tool.pytest.ini_options]
|
|
53
69
|
pythonpath = [".."]
|
|
54
70
|
testpaths = ["tests"]
|
|
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
|