cdk-factory 0.9.8__py3-none-any.whl → 0.9.10__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/app.py +49 -30
- cdk_factory/pipeline/pipeline_factory.py +2 -1
- cdk_factory/utilities/file_operations.py +11 -0
- cdk_factory/version.py +1 -1
- {cdk_factory-0.9.8.dist-info → cdk_factory-0.9.10.dist-info}/METADATA +1 -1
- {cdk_factory-0.9.8.dist-info → cdk_factory-0.9.10.dist-info}/RECORD +9 -9
- {cdk_factory-0.9.8.dist-info → cdk_factory-0.9.10.dist-info}/WHEEL +0 -0
- {cdk_factory-0.9.8.dist-info → cdk_factory-0.9.10.dist-info}/entry_points.txt +0 -0
- {cdk_factory-0.9.8.dist-info → cdk_factory-0.9.10.dist-info}/licenses/LICENSE +0 -0
cdk_factory/app.py
CHANGED
|
@@ -18,6 +18,7 @@ from aws_lambda_powertools import Logger
|
|
|
18
18
|
from cdk_factory.utilities.commandline_args import CommandlineArgs
|
|
19
19
|
from cdk_factory.workload.workload_factory import WorkloadFactory
|
|
20
20
|
from cdk_factory.utilities.configuration_loader import ConfigurationLoader
|
|
21
|
+
from cdk_factory.utilities.file_operations import FileOperations
|
|
21
22
|
from cdk_factory.version import __version__
|
|
22
23
|
|
|
23
24
|
|
|
@@ -36,36 +37,52 @@ class CdkAppFactory:
|
|
|
36
37
|
) -> None:
|
|
37
38
|
|
|
38
39
|
self.args = args or CommandlineArgs()
|
|
39
|
-
self.runtime_directory = runtime_directory
|
|
40
|
+
self.runtime_directory = runtime_directory
|
|
40
41
|
self.config_path: str | None = config_path
|
|
41
42
|
self.add_env_context = add_env_context
|
|
42
43
|
self._is_pipeline = is_pipeline
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#
|
|
50
|
-
supplied_outdir = outdir or (
|
|
51
|
-
|
|
44
|
+
|
|
45
|
+
if not self.runtime_directory and auto_detect_project_root:
|
|
46
|
+
self.runtime_directory = FileOperations.caller_app_dir()
|
|
47
|
+
|
|
48
|
+
print(f"📂 Runtime directory: {self.runtime_directory}")
|
|
49
|
+
|
|
50
|
+
# Handle outdir - backward compatible with smart defaults
|
|
51
|
+
supplied_outdir = outdir or (
|
|
52
|
+
self.args.outdir if hasattr(self.args, "outdir") else None
|
|
53
|
+
)
|
|
54
|
+
|
|
52
55
|
if supplied_outdir:
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
# If absolute path: use as-is (backward compatible)
|
|
57
|
+
if os.path.isabs(supplied_outdir):
|
|
58
|
+
self.outdir = supplied_outdir
|
|
59
|
+
else:
|
|
60
|
+
# If relative path/name: treat as namespace within /tmp/cdk-factory
|
|
61
|
+
namespace = supplied_outdir.rstrip("/")
|
|
62
|
+
if not namespace or namespace in (".", ".."):
|
|
63
|
+
namespace = "default"
|
|
64
|
+
# TODO: NOT SURE IF WE SHOULD DO THIS
|
|
65
|
+
self.outdir = f"/tmp/cdk-factory/{namespace}/cdk.out"
|
|
58
66
|
else:
|
|
59
|
-
# Default
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
# Default: cdk.out relative to runtime_directory (where app.py lives)
|
|
68
|
+
# This ensures CDK CLI can find it when running via cdk.json
|
|
69
|
+
self.outdir = str(Path(self.runtime_directory) / "cdk.out")
|
|
70
|
+
|
|
71
|
+
# Env or CLI still win if you want to honor them:
|
|
72
|
+
env_out = os.getenv("CDK_OUTDIR")
|
|
73
|
+
if env_out:
|
|
74
|
+
self.outdir = os.path.abspath(env_out)
|
|
75
|
+
print(f"[cdk-factory] CDK_OUTDIR override -> {self.outdir}")
|
|
76
|
+
|
|
62
77
|
# Clean and recreate directory for fresh synthesis
|
|
63
78
|
if os.path.exists(self.outdir):
|
|
64
79
|
shutil.rmtree(self.outdir)
|
|
65
80
|
os.makedirs(self.outdir, exist_ok=True)
|
|
66
|
-
|
|
81
|
+
|
|
67
82
|
self.app: aws_cdk.App = aws_cdk.App(outdir=self.outdir)
|
|
68
83
|
|
|
84
|
+
print(f"📂 CDK output directory: {self.outdir}")
|
|
85
|
+
|
|
69
86
|
def synth(
|
|
70
87
|
self,
|
|
71
88
|
cdk_app_file: str | None = None,
|
|
@@ -79,10 +96,12 @@ class CdkAppFactory:
|
|
|
79
96
|
"""
|
|
80
97
|
|
|
81
98
|
print(f"👋 Synthesizing CDK App from the cdk-factory version: {__version__}")
|
|
82
|
-
|
|
99
|
+
|
|
83
100
|
# Log consistent output directory
|
|
84
101
|
print(f"📂 CDK output directory: {self.outdir}")
|
|
85
|
-
print(
|
|
102
|
+
print(
|
|
103
|
+
f" └─ Consistent location works in both local and CodeBuild environments"
|
|
104
|
+
)
|
|
86
105
|
|
|
87
106
|
if not paths:
|
|
88
107
|
paths = []
|
|
@@ -117,24 +136,24 @@ class CdkAppFactory:
|
|
|
117
136
|
assembly: CloudAssembly = workload.synth()
|
|
118
137
|
|
|
119
138
|
print("☁️ cloud assembly dir", assembly.directory)
|
|
120
|
-
|
|
139
|
+
|
|
121
140
|
# Validate that the assembly directory exists and has files
|
|
122
141
|
self._validate_synth_output(assembly)
|
|
123
142
|
|
|
124
143
|
return assembly
|
|
125
|
-
|
|
144
|
+
|
|
126
145
|
def _validate_synth_output(self, assembly: CloudAssembly) -> None:
|
|
127
146
|
"""
|
|
128
147
|
Validate that CDK synthesis actually created the expected files.
|
|
129
|
-
|
|
148
|
+
|
|
130
149
|
Args:
|
|
131
150
|
assembly: The CloudAssembly returned from synth
|
|
132
|
-
|
|
151
|
+
|
|
133
152
|
Raises:
|
|
134
153
|
RuntimeError: If the output directory doesn't exist or is empty
|
|
135
154
|
"""
|
|
136
155
|
assembly_dir = Path(assembly.directory)
|
|
137
|
-
|
|
156
|
+
|
|
138
157
|
# Check if directory exists
|
|
139
158
|
if not assembly_dir.exists():
|
|
140
159
|
raise RuntimeError(
|
|
@@ -143,7 +162,7 @@ class CdkAppFactory:
|
|
|
143
162
|
f" Configured outdir: {self.outdir}\n"
|
|
144
163
|
f" Current directory: {os.getcwd()}"
|
|
145
164
|
)
|
|
146
|
-
|
|
165
|
+
|
|
147
166
|
# Check if directory has files
|
|
148
167
|
files = list(assembly_dir.iterdir())
|
|
149
168
|
if not files:
|
|
@@ -152,7 +171,7 @@ class CdkAppFactory:
|
|
|
152
171
|
f" Directory: {assembly_dir}\n"
|
|
153
172
|
f" This usually means CDK failed to write files."
|
|
154
173
|
)
|
|
155
|
-
|
|
174
|
+
|
|
156
175
|
# Check for manifest.json (key CDK file)
|
|
157
176
|
manifest = assembly_dir / "manifest.json"
|
|
158
177
|
if not manifest.exists():
|
|
@@ -162,13 +181,13 @@ class CdkAppFactory:
|
|
|
162
181
|
f" Files found: {[f.name for f in files]}\n"
|
|
163
182
|
f" CDK may have failed during synthesis."
|
|
164
183
|
)
|
|
165
|
-
|
|
184
|
+
|
|
166
185
|
# Success - log details
|
|
167
186
|
print(f"✅ CDK synthesis successful!")
|
|
168
187
|
print(f" └─ Output directory: {assembly_dir}")
|
|
169
188
|
print(f" └─ Files created: {len(files)}")
|
|
170
189
|
print(f" └─ Stacks: {len(assembly.stacks)}")
|
|
171
|
-
|
|
190
|
+
|
|
172
191
|
# Log stack names
|
|
173
192
|
if assembly.stacks:
|
|
174
193
|
stack_names = [stack.stack_name for stack in assembly.stacks]
|
|
@@ -361,7 +361,8 @@ class PipelineFactoryStack(IStack):
|
|
|
361
361
|
|
|
362
362
|
# Use consistent /tmp/cdk-factory/cdk.out location
|
|
363
363
|
# This matches the output directory configured in CdkAppFactory
|
|
364
|
-
cdk_out_directory = "/tmp/cdk-factory/cdk.out"
|
|
364
|
+
# cdk_out_directory = "/tmp/cdk-factory/cdk.out"
|
|
365
|
+
cdk_out_directory = self.workload.output_directory
|
|
365
366
|
|
|
366
367
|
# Debug logging - will be baked into buildspec
|
|
367
368
|
build_commands.append(f"echo '👉 CDK output directory: {cdk_out_directory}'")
|
|
@@ -6,6 +6,7 @@ MIT License. See Project Root for the license information.
|
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
8
|
import shutil
|
|
9
|
+
import inspect
|
|
9
10
|
import zipfile
|
|
10
11
|
from typing import List
|
|
11
12
|
from pathlib import Path
|
|
@@ -277,3 +278,13 @@ class FileOperations:
|
|
|
277
278
|
return sub_dir
|
|
278
279
|
|
|
279
280
|
return None
|
|
281
|
+
|
|
282
|
+
@staticmethod
|
|
283
|
+
def caller_app_dir(default: str = ".") -> str:
|
|
284
|
+
# frame[0] is this function; frame[1] is the factory; frame[2] should be app.py
|
|
285
|
+
for frame_info in inspect.stack():
|
|
286
|
+
# first non-package frame likely belongs to app.py
|
|
287
|
+
candidate = os.path.abspath(os.path.dirname(frame_info.filename))
|
|
288
|
+
if "site-packages" not in candidate and "dist-packages" not in candidate:
|
|
289
|
+
return candidate
|
|
290
|
+
return os.path.abspath(default)
|
cdk_factory/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.9.
|
|
1
|
+
__version__ = "0.9.10"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
cdk_factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cdk_factory/app.py,sha256=
|
|
2
|
+
cdk_factory/app.py,sha256=VPO4ohK54hcWJa9Auq06t0oAW2nLekMGjSxAnxUWCvs,9640
|
|
3
3
|
cdk_factory/cdk.json,sha256=SKZKhJ2PBpFH78j-F8S3VDYW-lf76--Q2I3ON-ZIQfw,3106
|
|
4
4
|
cdk_factory/cli.py,sha256=FGbCTS5dYCNsfp-etshzvFlGDCjC28r6rtzYbe7KoHI,6407
|
|
5
|
-
cdk_factory/version.py,sha256=
|
|
5
|
+
cdk_factory/version.py,sha256=5nY2lKMmQwtU8FXTQ2Qpv9EUNfy2UJF9cHFr82n7ARw,23
|
|
6
6
|
cdk_factory/builds/README.md,sha256=9BBWd7bXpyKdMU_g2UljhQwrC9i5O_Tvkb6oPvndoZk,90
|
|
7
7
|
cdk_factory/commands/command_loader.py,sha256=QbLquuP_AdxtlxlDy-2IWCQ6D-7qa58aphnDPtp_uTs,3744
|
|
8
8
|
cdk_factory/configurations/base_config.py,sha256=JKjhNsy0RCUZy1s8n5D_aXXI-upR9izaLtCTfKYiV9k,9624
|
|
@@ -65,7 +65,7 @@ cdk_factory/interfaces/live_ssm_resolver.py,sha256=3FIr9a02SXqZmbFs3RT0WxczWEQR_
|
|
|
65
65
|
cdk_factory/interfaces/ssm_parameter_mixin.py,sha256=uA2j8HmAOpuEA9ynRj51s0WjUHMVLsbLQN-QS9NKyHA,12089
|
|
66
66
|
cdk_factory/lambdas/health_handler.py,sha256=dd40ykKMxWCFEIyp2ZdQvAGNjw_ylI9CSm1N24Hp2ME,196
|
|
67
67
|
cdk_factory/pipeline/path_utils.py,sha256=fvWdrcb4onmpIu1APkHLhXg8zWfK74HcW3Ra2ynxfXM,2586
|
|
68
|
-
cdk_factory/pipeline/pipeline_factory.py,sha256=
|
|
68
|
+
cdk_factory/pipeline/pipeline_factory.py,sha256=PqaPu5tQpkMObSgoHUxVcuA5UoI8CaMRiX2jx4XTg9c,16111
|
|
69
69
|
cdk_factory/pipeline/stage.py,sha256=Be7ExMB9A-linRM18IQDOzQ-cP_I2_ThRNzlT4FIrUg,437
|
|
70
70
|
cdk_factory/pipeline/security/policies.py,sha256=H3-S6nipz3UtF9Pc5eJYr4-aREUTCaJWMjOUyd6Rdv4,4406
|
|
71
71
|
cdk_factory/pipeline/security/roles.py,sha256=ZB_O5H_BXgotvVspS2kVad9EMcY-a_-vU7Nm1_Z5MB8,4985
|
|
@@ -113,15 +113,15 @@ cdk_factory/utilities/commandline_args.py,sha256=0FiNEJFbWVN8Ct7r0VHnJEx7rhUlaRK
|
|
|
113
113
|
cdk_factory/utilities/configuration_loader.py,sha256=z0ZdGLNbTO4_yfluB9zUh_i_Poc9qj-7oRyjMRlNkN8,1522
|
|
114
114
|
cdk_factory/utilities/docker_utilities.py,sha256=9r8C-lXYpymqEfi3gTeWCQzHldvfjttPqn6p3j2khTE,8111
|
|
115
115
|
cdk_factory/utilities/environment_services.py,sha256=cd2T0efJtFPMLa1Fm7MPL-sqUlhKXCB7_XHsR8sfymE,9696
|
|
116
|
-
cdk_factory/utilities/file_operations.py,sha256=
|
|
116
|
+
cdk_factory/utilities/file_operations.py,sha256=fxqT0iyYZkb46lQr_XXadhFTca_1neVW0VRVkbyMmhA,9462
|
|
117
117
|
cdk_factory/utilities/git_utilities.py,sha256=7Xac8PaThc7Lmk5jtDBHaJOj-fWRT017cgZmgXkVizM,3155
|
|
118
118
|
cdk_factory/utilities/json_loading_utility.py,sha256=YRgzA1I-B_HwZm1eWJTeQ1JLkebCL4C1gpHOqo6GkCA,10341
|
|
119
119
|
cdk_factory/utilities/lambda_function_utilities.py,sha256=S1GvBsY_q2cyUiaud3HORJMnLhI5cRi31fbeaktY-_Q,15826
|
|
120
120
|
cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITEP7EuSU,1019
|
|
121
121
|
cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
|
|
122
122
|
cdk_factory/workload/workload_factory.py,sha256=yBUDGIuB8-5p_mGcVFxsD2ZoZIziak3yh3LL3JvS0M4,5903
|
|
123
|
-
cdk_factory-0.9.
|
|
124
|
-
cdk_factory-0.9.
|
|
125
|
-
cdk_factory-0.9.
|
|
126
|
-
cdk_factory-0.9.
|
|
127
|
-
cdk_factory-0.9.
|
|
123
|
+
cdk_factory-0.9.10.dist-info/METADATA,sha256=B9EhOfGJhkb_Du8nOE5NmJ0A-YqDU0ou8a6l6o7E8GM,2451
|
|
124
|
+
cdk_factory-0.9.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
125
|
+
cdk_factory-0.9.10.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
|
|
126
|
+
cdk_factory-0.9.10.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
|
|
127
|
+
cdk_factory-0.9.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|