cdk-factory 0.8.2__py3-none-any.whl → 0.8.4__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 cdk-factory might be problematic. Click here for more details.
- cdk_factory/stack_library/api_gateway/api_gateway_stack.py +16 -7
- cdk_factory/utilities/json_loading_utility.py +30 -6
- cdk_factory/utilities/lambda_function_utilities.py +16 -2
- cdk_factory/version.py +1 -1
- {cdk_factory-0.8.2.dist-info → cdk_factory-0.8.4.dist-info}/METADATA +1 -1
- {cdk_factory-0.8.2.dist-info → cdk_factory-0.8.4.dist-info}/RECORD +8 -8
- {cdk_factory-0.8.2.dist-info → cdk_factory-0.8.4.dist-info}/WHEEL +0 -0
- {cdk_factory-0.8.2.dist-info → cdk_factory-0.8.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -332,6 +332,19 @@ class ApiGatewayStack(IStack, EnhancedSsmParameterMixin):
|
|
|
332
332
|
api_gateway, route_config, self.stack_config, api_id
|
|
333
333
|
)
|
|
334
334
|
|
|
335
|
+
def _get_route_suffix(self, route: dict) -> str:
|
|
336
|
+
"""
|
|
337
|
+
Calculate a unique suffix for route construct IDs.
|
|
338
|
+
Uses 'name' field if provided, otherwise includes method + path for uniqueness.
|
|
339
|
+
"""
|
|
340
|
+
if "name" in route and route["name"]:
|
|
341
|
+
return route["name"] # Use the unique name provided in config
|
|
342
|
+
else:
|
|
343
|
+
# Include method to ensure uniqueness when same path has multiple methods
|
|
344
|
+
method = route.get("method", "GET").upper()
|
|
345
|
+
path_suffix = route["path"].strip("/").replace("/", "-") or "health"
|
|
346
|
+
return f"{method.lower()}-{path_suffix}"
|
|
347
|
+
|
|
335
348
|
def _setup_lambda_routes(self, api_gateway, api_id, routes, authorizer):
|
|
336
349
|
"""Setup Lambda routes and integrations"""
|
|
337
350
|
for route in routes:
|
|
@@ -352,7 +365,7 @@ class ApiGatewayStack(IStack, EnhancedSsmParameterMixin):
|
|
|
352
365
|
This is the NEW PATTERN for separating Lambda and API Gateway stacks.
|
|
353
366
|
"""
|
|
354
367
|
route_path = route["path"]
|
|
355
|
-
suffix =
|
|
368
|
+
suffix = self._get_route_suffix(route) # Use shared method for consistent suffix calculation
|
|
356
369
|
|
|
357
370
|
# Get Lambda ARN from SSM Parameter Store
|
|
358
371
|
lambda_arn = self._get_lambda_arn_from_ssm(route)
|
|
@@ -436,12 +449,8 @@ class ApiGatewayStack(IStack, EnhancedSsmParameterMixin):
|
|
|
436
449
|
return None
|
|
437
450
|
|
|
438
451
|
def _setup_single_lambda_route(self, api_gateway, api_id, route, authorizer):
|
|
439
|
-
"""
|
|
440
|
-
|
|
441
|
-
LEGACY PATTERN: Creates a new Lambda function inline.
|
|
442
|
-
Prefer _setup_existing_lambda_route for new implementations.
|
|
443
|
-
"""
|
|
444
|
-
suffix = route["path"].strip("/").replace("/", "-") or "health"
|
|
452
|
+
"""Setup a single Lambda route with integration and CORS"""
|
|
453
|
+
suffix = self._get_route_suffix(route) # Use shared method for consistent suffix calculation
|
|
445
454
|
src = route.get("src")
|
|
446
455
|
handler = route.get("handler")
|
|
447
456
|
|
|
@@ -14,16 +14,30 @@ class JsonLoadingUtility:
|
|
|
14
14
|
"""
|
|
15
15
|
JSON Loading Utility
|
|
16
16
|
This class is used to load a JSON file. We have a special syntax that allows
|
|
17
|
-
chaining JSON files together using __inherits__
|
|
17
|
+
chaining JSON files together using __imports__ or __inherits__ (legacy).
|
|
18
|
+
|
|
19
|
+
The __imports__ keyword allows you to:
|
|
20
|
+
- Import from external JSON files: "__imports__": "./base-config.json"
|
|
21
|
+
- Import from nested sections: "__imports__": "workload.defaults"
|
|
22
|
+
- Import from directories: "__imports__": "./configs/"
|
|
23
|
+
- Import multiple sources: "__imports__": ["base.json", "overrides.json"]
|
|
18
24
|
|
|
19
25
|
Examples:
|
|
20
|
-
|
|
26
|
+
# Single file import
|
|
27
|
+
{"__imports__": "./base-config.json", "name": "override"}
|
|
28
|
+
|
|
29
|
+
# Multiple imports (merged in order)
|
|
30
|
+
{"__imports__": ["base.json", "env-specific.json"]}
|
|
31
|
+
|
|
32
|
+
# Nested section reference
|
|
33
|
+
{"__imports__": "workload.defaults.lambda"}
|
|
21
34
|
"""
|
|
22
35
|
|
|
23
36
|
def __init__(self, path) -> None:
|
|
24
37
|
self.path = path
|
|
25
38
|
self.base_path = os.path.dirname(path)
|
|
26
|
-
|
|
39
|
+
# Support both __imports__ (preferred) and __inherits__ (legacy)
|
|
40
|
+
self.import_keys = ["__imports__", "__inherits__"]
|
|
27
41
|
|
|
28
42
|
def load(self):
|
|
29
43
|
"""Load and parse the JSON object for nested resources."""
|
|
@@ -60,14 +74,24 @@ class JsonLoadingUtility:
|
|
|
60
74
|
):
|
|
61
75
|
"""Resolve references in a configuration section."""
|
|
62
76
|
if isinstance(section, dict):
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
# Check for import keys (try __imports__ first, fall back to __inherits__)
|
|
78
|
+
import_key = None
|
|
79
|
+
for key in self.import_keys:
|
|
80
|
+
if key in section:
|
|
81
|
+
import_key = key
|
|
82
|
+
break
|
|
83
|
+
|
|
84
|
+
if import_key:
|
|
85
|
+
nested_paths = section.pop(import_key)
|
|
65
86
|
|
|
66
87
|
# Support both single path (string) and multiple paths (list)
|
|
67
88
|
if isinstance(nested_paths, str):
|
|
68
89
|
nested_paths = [nested_paths]
|
|
69
90
|
elif not isinstance(nested_paths, list):
|
|
70
|
-
raise ValueError(
|
|
91
|
+
raise ValueError(
|
|
92
|
+
f"{import_key} must be a string or list of paths, got {type(nested_paths)}. "
|
|
93
|
+
f"Example: '{import_key}': './base.json' or '{import_key}': ['base.json', 'overrides.json']"
|
|
94
|
+
)
|
|
71
95
|
|
|
72
96
|
# Process each path and merge results
|
|
73
97
|
merged_section = None
|
|
@@ -295,7 +295,20 @@ class LambdaFunctionUtilities:
|
|
|
295
295
|
if not os.path.exists(lambda_directory):
|
|
296
296
|
raise FileNotFoundError(f"directory not found: {lambda_directory}")
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
# Copy lambda directory, excluding __pycache__ and other build artifacts
|
|
299
|
+
def ignore_patterns(directory, files):
|
|
300
|
+
"""Ignore __pycache__, .pyc files, and other build artifacts"""
|
|
301
|
+
return [
|
|
302
|
+
f for f in files
|
|
303
|
+
if f == '__pycache__'
|
|
304
|
+
or f.endswith('.pyc')
|
|
305
|
+
or f.endswith('.pyo')
|
|
306
|
+
or f == '.pytest_cache'
|
|
307
|
+
or f == '.mypy_cache'
|
|
308
|
+
or f == '__pycache__'
|
|
309
|
+
]
|
|
310
|
+
|
|
311
|
+
shutil.copytree(lambda_directory, output_dir, dirs_exist_ok=True, ignore=ignore_patterns)
|
|
299
312
|
|
|
300
313
|
def __requirements(
|
|
301
314
|
self,
|
|
@@ -377,7 +390,8 @@ class LambdaFunctionUtilities:
|
|
|
377
390
|
logger.warning(f"CodeArtifact login failed (continuing): {e}")
|
|
378
391
|
# Continue with other logins or pip install
|
|
379
392
|
|
|
380
|
-
|
|
393
|
+
# Use --upgrade to avoid warnings about existing directories
|
|
394
|
+
commands = f"pip install -r {requirement} -t {output_dir} --upgrade".split()
|
|
381
395
|
subprocess.check_call(commands)
|
|
382
396
|
else:
|
|
383
397
|
logger.warning(
|
cdk_factory/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.8.
|
|
1
|
+
__version__ = "0.8.4"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
cdk_factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
cdk_factory/app.py,sha256=xv863N7O6HPKznB68_t7O4la9JacrkG87t9TjoDUk7s,2827
|
|
3
3
|
cdk_factory/cdk.json,sha256=SKZKhJ2PBpFH78j-F8S3VDYW-lf76--Q2I3ON-ZIQfw,3106
|
|
4
|
-
cdk_factory/version.py,sha256=
|
|
4
|
+
cdk_factory/version.py,sha256=jhHEJFZWhkQDemoZMomBYq-RNrKXknYzUaeIU9A6XsI,22
|
|
5
5
|
cdk_factory/builds/README.md,sha256=9BBWd7bXpyKdMU_g2UljhQwrC9i5O_Tvkb6oPvndoZk,90
|
|
6
6
|
cdk_factory/commands/command_loader.py,sha256=QbLquuP_AdxtlxlDy-2IWCQ6D-7qa58aphnDPtp_uTs,3744
|
|
7
7
|
cdk_factory/configurations/base_config.py,sha256=JKjhNsy0RCUZy1s8n5D_aXXI-upR9izaLtCTfKYiV9k,9624
|
|
@@ -73,7 +73,7 @@ cdk_factory/stack/stack_module_registry.py,sha256=J14-A75VZESzRQa8p-Fepdap7Z8T7m
|
|
|
73
73
|
cdk_factory/stack/stack_modules.py,sha256=kgEK-j0smZPozVwTCfM1g1V17EyTBT0TXAQZq4vZz0o,784
|
|
74
74
|
cdk_factory/stack_library/__init__.py,sha256=5Y9TpIe8ZK1688G60PGcuP-hM0RvYEY_3Hl2qJCJJrw,581
|
|
75
75
|
cdk_factory/stack_library/stack_base.py,sha256=tTleSFmlf26DuKVF_ytftf8P7IVWb5iex8cYfYupfvQ,4940
|
|
76
|
-
cdk_factory/stack_library/api_gateway/api_gateway_stack.py,sha256=
|
|
76
|
+
cdk_factory/stack_library/api_gateway/api_gateway_stack.py,sha256=BWhawbwGHggKQN3QLolZhdECoeTTnTBTrRo2hTJC570,38469
|
|
77
77
|
cdk_factory/stack_library/auto_scaling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
78
|
cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py,sha256=UsFqUb_3XPJAlmZ6F75nXna3elOggD1KuFmmdmhi0Lg,19070
|
|
79
79
|
cdk_factory/stack_library/aws_lambdas/lambda_stack.py,sha256=SFbBPvvCopbyiuYtq-O5sQkFCf94Wzua6aDUXiFDSB4,26161
|
|
@@ -107,12 +107,12 @@ cdk_factory/utilities/docker_utilities.py,sha256=9r8C-lXYpymqEfi3gTeWCQzHldvfjtt
|
|
|
107
107
|
cdk_factory/utilities/environment_services.py,sha256=cd2T0efJtFPMLa1Fm7MPL-sqUlhKXCB7_XHsR8sfymE,9696
|
|
108
108
|
cdk_factory/utilities/file_operations.py,sha256=HCZevKlmnHNB2wkIEPtdm-g2nJSKT3B9uipLk8Kx_Yk,8946
|
|
109
109
|
cdk_factory/utilities/git_utilities.py,sha256=7Xac8PaThc7Lmk5jtDBHaJOj-fWRT017cgZmgXkVizM,3155
|
|
110
|
-
cdk_factory/utilities/json_loading_utility.py,sha256=
|
|
111
|
-
cdk_factory/utilities/lambda_function_utilities.py,sha256=
|
|
110
|
+
cdk_factory/utilities/json_loading_utility.py,sha256=YRgzA1I-B_HwZm1eWJTeQ1JLkebCL4C1gpHOqo6GkCA,10341
|
|
111
|
+
cdk_factory/utilities/lambda_function_utilities.py,sha256=S1GvBsY_q2cyUiaud3HORJMnLhI5cRi31fbeaktY-_Q,15826
|
|
112
112
|
cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITEP7EuSU,1019
|
|
113
113
|
cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
|
|
114
114
|
cdk_factory/workload/workload_factory.py,sha256=yBUDGIuB8-5p_mGcVFxsD2ZoZIziak3yh3LL3JvS0M4,5903
|
|
115
|
-
cdk_factory-0.8.
|
|
116
|
-
cdk_factory-0.8.
|
|
117
|
-
cdk_factory-0.8.
|
|
118
|
-
cdk_factory-0.8.
|
|
115
|
+
cdk_factory-0.8.4.dist-info/METADATA,sha256=572maX0Tw7QqvxXl2uv9m9eL3sFTGU8ecVlQS5SdfLY,2450
|
|
116
|
+
cdk_factory-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
117
|
+
cdk_factory-0.8.4.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
|
|
118
|
+
cdk_factory-0.8.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|