cdk-factory 0.8.8__tar.gz → 0.9.0__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.
Potentially problematic release.
This version of cdk-factory might be problematic. Click here for more details.
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/PKG-INFO +1 -1
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/pyproject.toml +5 -2
- cdk_factory-0.9.0/src/cdk_factory/app.py +222 -0
- cdk_factory-0.9.0/src/cdk_factory/cli.py +200 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/pipeline/pipeline_factory.py +10 -1
- cdk_factory-0.9.0/src/cdk_factory/templates/README.md +99 -0
- cdk_factory-0.9.0/src/cdk_factory/templates/app.py.template +36 -0
- cdk_factory-0.9.0/src/cdk_factory/templates/cdk.json.template +73 -0
- cdk_factory-0.9.0/src/cdk_factory/version.py +1 -0
- cdk_factory-0.8.8/BUG_FIX_SSM_IMPORTS_METADATA_FIELDS.md +0 -123
- cdk_factory-0.8.8/CHANGELOG_v0.8.1.md +0 -148
- cdk_factory-0.8.8/CHANGELOG_v0.8.2.md +0 -391
- cdk_factory-0.8.8/CHANGELOG_v0.8.3.md +0 -223
- cdk_factory-0.8.8/LAMBDA_PERMISSION_FIX_SUMMARY.md +0 -56
- cdk_factory-0.8.8/RELEASE_NOTES_v0.8.2.md +0 -289
- cdk_factory-0.8.8/SUMMARY_v0.8.2.md +0 -335
- cdk_factory-0.8.8/SUMMARY_v0.8.3.md +0 -146
- cdk_factory-0.8.8/src/cdk_factory/app.py +0 -92
- cdk_factory-0.8.8/src/cdk_factory/version.py +0 -1
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/.gitignore +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/.windsurfrules +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/LICENSE +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/archive/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/archive/migrate_to_enhanced_ssm.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/examples/json-imports/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/examples/separate-api-gateway/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/examples/separate-api-gateway/api-gateway-stack.json +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/examples/separate-api-gateway/config.json +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/examples/separate-api-gateway/lambda-stack.json +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/mypy.ini +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/publish_to_pypi.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/publish_to_pypi.sh +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/pysetup.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/pysetup.sh +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/requirements.dev.txt +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/requirements.tests.txt +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/requirements.txt +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/run-checks.sh +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/run-tests-clean-venv.sh +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/run-tests.sh +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/builds/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/cdk.json +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/commands/command_loader.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/base_config.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/cdk_config.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/deployment.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/deployment_wave.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/devops.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/enhanced_base_config.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/enhanced_ssm_config.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/management.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/pipeline.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/pipeline_stage.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/_resources.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/api_gateway.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/apigateway_route_config.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/auto_scaling.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/cloudfront.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/cloudwatch_widget.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/code_artifact.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/code_artifact_login.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/code_repository.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/cognito.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/docker.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/dynamodb.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/ecr.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/ecs_service.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/exisiting.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/lambda_function.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/lambda_layers.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/lambda_triggers.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/load_balancer.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/rds.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/resource_mapping.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/resource_naming.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/resource_types.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/route53.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/route53_hosted_zone.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/rum.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/s3.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/security_group.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/security_group_full_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/sqs.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/resources/vpc.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/configurations/workload.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/ecr/ecr_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/lambdas/lambda_function_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/lambdas/lambda_function_docker_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/lambdas/lambda_function_role_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/lambdas/policies/policy_docs.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/lambdas/policies/policy_statements.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_destination_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_source_construct.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/constructs/sqs/policies/sqs_policies.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/interfaces/enhanced_ssm_parameter_mixin.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/interfaces/istack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/interfaces/live_ssm_resolver.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/interfaces/ssm_parameter_mixin.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/lambdas/health_handler.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/pipeline/security/policies.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/pipeline/security/roles.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/pipeline/stage.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack/istack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack/stack_factory.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack/stack_module_loader.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack/stack_module_registry.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack/stack_modules.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/api_gateway/api_gateway_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/auto_scaling/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/aws_lambdas/lambda_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/buckets/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/buckets/bucket_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/code_artifact/code_artifact_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/cognito/cognito_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/dynamodb/dynamodb_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/ecr/README.md +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/ecr/ecr_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/ecs/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/ecs/ecs_service_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/load_balancer/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/load_balancer/load_balancer_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/rds/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/rds/rds_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/route53/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/route53/route53_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/rum/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/rum/rum_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/security_group/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/security_group/security_group_full_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/security_group/security_group_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/simple_queue_service/sqs_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/stack_base.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/vpc/__init__.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/vpc/vpc_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stack_library/websites/static_website_stack.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/stages/websites/static_website_stage.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/api_gateway_integration_utility.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/commandline_args.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/configuration_loader.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/docker_utilities.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/environment_services.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/file_operations.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/git_utilities.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/json_loading_utility.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/lambda_function_utilities.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utilities/os_execute.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/utils/api_gateway_utilities.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/cdk_factory/workload/workload_factory.py +0 -0
- {cdk_factory-0.8.8 → cdk_factory-0.9.0}/src/handlers/test/handler.py +0 -0
|
@@ -33,7 +33,7 @@ markers = [
|
|
|
33
33
|
[project]
|
|
34
34
|
|
|
35
35
|
name = "cdk_factory"
|
|
36
|
-
version = "0.
|
|
36
|
+
version = "0.9.0"
|
|
37
37
|
authors = [
|
|
38
38
|
{ name="Eric Wilson", email="eric.wilson@geekcafe.com" }
|
|
39
39
|
]
|
|
@@ -54,4 +54,7 @@ dependencies = [
|
|
|
54
54
|
"boto3_assist>=0.10.0",
|
|
55
55
|
"PyYAML",
|
|
56
56
|
"cdk_nag"
|
|
57
|
-
]
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[project.scripts]
|
|
60
|
+
cdk-factory = "cdk_factory.cli:main"
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Geek Cafe, LLC
|
|
4
|
+
Maintainers: Eric Wilson
|
|
5
|
+
MIT License. See Project Root for the license information.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
import aws_cdk
|
|
10
|
+
from aws_cdk.cx_api import CloudAssembly
|
|
11
|
+
|
|
12
|
+
from cdk_factory.utilities.commandline_args import CommandlineArgs
|
|
13
|
+
from cdk_factory.workload.workload_factory import WorkloadFactory
|
|
14
|
+
from cdk_factory.utilities.configuration_loader import ConfigurationLoader
|
|
15
|
+
from cdk_factory.version import __version__
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CdkAppFactory:
|
|
19
|
+
"""CDK App Wrapper"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
args: CommandlineArgs | None = None,
|
|
24
|
+
runtime_directory: str | None = None,
|
|
25
|
+
config_path: str | None = None,
|
|
26
|
+
outdir: str | None = None,
|
|
27
|
+
add_env_context: bool = True,
|
|
28
|
+
auto_detect_project_root: bool = True,
|
|
29
|
+
is_pipeline: bool = False,
|
|
30
|
+
) -> None:
|
|
31
|
+
|
|
32
|
+
self.args = args or CommandlineArgs()
|
|
33
|
+
self.runtime_directory = runtime_directory or str(Path(__file__).parent)
|
|
34
|
+
self.config_path: str | None = config_path
|
|
35
|
+
self.add_env_context = add_env_context
|
|
36
|
+
self._is_pipeline = is_pipeline
|
|
37
|
+
|
|
38
|
+
# Auto-detect outdir for CodeBuild compatibility
|
|
39
|
+
if outdir is None and self.args.outdir is None and auto_detect_project_root:
|
|
40
|
+
# Always detect project root first
|
|
41
|
+
project_root = self._detect_project_root()
|
|
42
|
+
|
|
43
|
+
# Check if we're in CodeBuild or building a pipeline
|
|
44
|
+
in_codebuild = bool(os.getenv('CODEBUILD_SRC_DIR'))
|
|
45
|
+
|
|
46
|
+
# Auto-detect if this is a pipeline deployment by checking config
|
|
47
|
+
is_pipeline_deployment = is_pipeline or self._check_if_pipeline_deployment(config_path)
|
|
48
|
+
|
|
49
|
+
if in_codebuild or is_pipeline_deployment:
|
|
50
|
+
# For pipelines, calculate relative path from runtime_directory to project_root/cdk.out
|
|
51
|
+
# This ensures cdk.out is always at project root, even when app.py is in subdirectory
|
|
52
|
+
runtime_path = Path(self.runtime_directory).resolve()
|
|
53
|
+
project_path = Path(project_root).resolve()
|
|
54
|
+
cdk_out_path = project_path / 'cdk.out'
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
# Calculate relative path from runtime directory to project_root/cdk.out
|
|
58
|
+
relative_path = os.path.relpath(cdk_out_path, runtime_path)
|
|
59
|
+
self.outdir = relative_path
|
|
60
|
+
if in_codebuild:
|
|
61
|
+
print(f"📦 CodeBuild detected: using relative path '{relative_path}'")
|
|
62
|
+
else:
|
|
63
|
+
print(f"📦 Pipeline deployment detected: using relative path '{relative_path}'")
|
|
64
|
+
except ValueError:
|
|
65
|
+
# If paths are on different drives (Windows), fallback to absolute
|
|
66
|
+
self.outdir = str(cdk_out_path)
|
|
67
|
+
else:
|
|
68
|
+
# For local dev, use absolute path at project root
|
|
69
|
+
self.outdir = os.path.join(project_root, 'cdk.out')
|
|
70
|
+
else:
|
|
71
|
+
self.outdir = outdir or self.args.outdir
|
|
72
|
+
|
|
73
|
+
self.app: aws_cdk.App = aws_cdk.App(outdir=self.outdir)
|
|
74
|
+
|
|
75
|
+
def synth(
|
|
76
|
+
self,
|
|
77
|
+
cdk_app_file: str | None = None,
|
|
78
|
+
paths: list[str] | None = None,
|
|
79
|
+
**kwargs,
|
|
80
|
+
) -> CloudAssembly:
|
|
81
|
+
"""
|
|
82
|
+
The AWS CDK Deployment pipeline is defined here
|
|
83
|
+
Returns:
|
|
84
|
+
CloudAssembly: CDK CloudAssembly
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
print(f"👋 Synthesizing CDK App from the cdk-factory version: {__version__}")
|
|
88
|
+
|
|
89
|
+
if not paths:
|
|
90
|
+
paths = []
|
|
91
|
+
|
|
92
|
+
paths.append(self.app.outdir)
|
|
93
|
+
paths.append(__file__)
|
|
94
|
+
if cdk_app_file:
|
|
95
|
+
paths.append(cdk_app_file)
|
|
96
|
+
|
|
97
|
+
self.config_path = ConfigurationLoader().get_runtime_config(
|
|
98
|
+
relative_config_path=self.config_path,
|
|
99
|
+
args=self.args,
|
|
100
|
+
app=self.app,
|
|
101
|
+
runtime_directory=self.runtime_directory,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
print("config_path", self.config_path)
|
|
105
|
+
if not self.config_path:
|
|
106
|
+
raise Exception("No configuration file provided")
|
|
107
|
+
if not os.path.exists(self.config_path):
|
|
108
|
+
raise Exception("Configuration file does not exist: " + self.config_path)
|
|
109
|
+
workload: WorkloadFactory = WorkloadFactory(
|
|
110
|
+
app=self.app,
|
|
111
|
+
config_path=self.config_path,
|
|
112
|
+
cdk_app_file=cdk_app_file,
|
|
113
|
+
paths=paths,
|
|
114
|
+
runtime_directory=self.runtime_directory,
|
|
115
|
+
outdir=self.outdir,
|
|
116
|
+
add_env_context=self.add_env_context,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
assembly: CloudAssembly = workload.synth()
|
|
120
|
+
|
|
121
|
+
print("☁️ cloud assembly dir", assembly.directory)
|
|
122
|
+
|
|
123
|
+
return assembly
|
|
124
|
+
|
|
125
|
+
def _detect_project_root(self) -> str:
|
|
126
|
+
"""
|
|
127
|
+
Detect project root directory for proper cdk.out placement
|
|
128
|
+
|
|
129
|
+
Priority:
|
|
130
|
+
1. CODEBUILD_SRC_DIR (CodeBuild environment)
|
|
131
|
+
2. Find project markers (pyproject.toml, package.json, .git, etc.)
|
|
132
|
+
3. Assume devops/cdk-iac structure (go up 2 levels)
|
|
133
|
+
4. Fallback to runtime_directory
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
str: Absolute path to project root
|
|
137
|
+
"""
|
|
138
|
+
# Priority 1: CodeBuild environment (most reliable)
|
|
139
|
+
codebuild_src = os.getenv("CODEBUILD_SRC_DIR")
|
|
140
|
+
if codebuild_src:
|
|
141
|
+
return str(Path(codebuild_src).resolve())
|
|
142
|
+
|
|
143
|
+
# Priority 2: Look for project root markers
|
|
144
|
+
# CodeBuild often gets zip without .git, so check multiple markers
|
|
145
|
+
current = Path(self.runtime_directory).resolve()
|
|
146
|
+
|
|
147
|
+
# Walk up the directory tree looking for root markers
|
|
148
|
+
for parent in [current] + list(current.parents):
|
|
149
|
+
# Check for common project root indicators
|
|
150
|
+
root_markers = [
|
|
151
|
+
".git", # Git repo (local dev)
|
|
152
|
+
"pyproject.toml", # Python project root
|
|
153
|
+
"package.json", # Node project root
|
|
154
|
+
"Cargo.toml", # Rust project root
|
|
155
|
+
".gitignore", # Often at root
|
|
156
|
+
"README.md", # Often at root
|
|
157
|
+
"requirements.txt", # Python dependencies
|
|
158
|
+
]
|
|
159
|
+
|
|
160
|
+
# If we find multiple markers at this level, it's likely the root
|
|
161
|
+
markers_found = sum(
|
|
162
|
+
1 for marker in root_markers if (parent / marker).exists()
|
|
163
|
+
)
|
|
164
|
+
if markers_found >= 2 and parent != current:
|
|
165
|
+
return str(parent)
|
|
166
|
+
|
|
167
|
+
# Priority 3: Assume devops/cdk-iac structure
|
|
168
|
+
# If runtime_directory ends with devops/cdk-iac, go up 2 levels
|
|
169
|
+
parts = current.parts
|
|
170
|
+
if len(parts) >= 2 and parts[-2:] == ("devops", "cdk-iac"):
|
|
171
|
+
return str(current.parent.parent)
|
|
172
|
+
|
|
173
|
+
# Also try just 'cdk-iac' or 'devops'
|
|
174
|
+
if len(parts) >= 1 and parts[-1] in (
|
|
175
|
+
"cdk-iac",
|
|
176
|
+
"devops",
|
|
177
|
+
"infrastructure",
|
|
178
|
+
"iac",
|
|
179
|
+
):
|
|
180
|
+
# Go up until we're not in these directories
|
|
181
|
+
potential_root = current.parent
|
|
182
|
+
while potential_root.name in ("devops", "cdk-iac", "infrastructure", "iac"):
|
|
183
|
+
potential_root = potential_root.parent
|
|
184
|
+
return str(potential_root)
|
|
185
|
+
|
|
186
|
+
# Priority 4: Fallback to runtime_directory
|
|
187
|
+
return str(current)
|
|
188
|
+
|
|
189
|
+
def _check_if_pipeline_deployment(self, config_path: str | None) -> bool:
|
|
190
|
+
"""
|
|
191
|
+
Check if the configuration includes pipeline deployments with CI/CD enabled.
|
|
192
|
+
Returns True if pipelines are detected, False otherwise.
|
|
193
|
+
"""
|
|
194
|
+
if not config_path or not os.path.exists(config_path):
|
|
195
|
+
return False
|
|
196
|
+
|
|
197
|
+
try:
|
|
198
|
+
import json
|
|
199
|
+
with open(config_path, 'r') as f:
|
|
200
|
+
config = json.load(f)
|
|
201
|
+
|
|
202
|
+
# Check for workload.deployments with CI/CD enabled
|
|
203
|
+
workload = config.get('workload', {})
|
|
204
|
+
deployments = workload.get('deployments', [])
|
|
205
|
+
|
|
206
|
+
for deployment in deployments:
|
|
207
|
+
devops = deployment.get('devops', {})
|
|
208
|
+
ci_cd = devops.get('ci_cd', {})
|
|
209
|
+
if ci_cd.get('enabled', False):
|
|
210
|
+
return True
|
|
211
|
+
|
|
212
|
+
return False
|
|
213
|
+
except:
|
|
214
|
+
# If we can't read/parse the config, assume not a pipeline
|
|
215
|
+
return False
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
if __name__ == "__main__":
|
|
219
|
+
# deploy_test()
|
|
220
|
+
cmd_args: CommandlineArgs = CommandlineArgs()
|
|
221
|
+
cdk_app: CdkAppFactory = CdkAppFactory(args=cmd_args)
|
|
222
|
+
cdk_app.synth()
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CDK Factory CLI
|
|
4
|
+
|
|
5
|
+
Provides convenience commands for initializing and managing cdk-factory projects.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import os
|
|
10
|
+
import shutil
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Optional
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CdkFactoryCLI:
|
|
16
|
+
"""CLI for cdk-factory project management"""
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
self.package_root = Path(__file__).parent.resolve()
|
|
20
|
+
self.templates_dir = self.package_root / "templates"
|
|
21
|
+
|
|
22
|
+
# Verify templates directory exists
|
|
23
|
+
if not self.templates_dir.exists():
|
|
24
|
+
raise RuntimeError(
|
|
25
|
+
f"Templates directory not found at {self.templates_dir}. "
|
|
26
|
+
"Please ensure cdk-factory is properly installed."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def init_project(
|
|
30
|
+
self,
|
|
31
|
+
target_dir: str,
|
|
32
|
+
workload_name: Optional[str] = None,
|
|
33
|
+
environment: Optional[str] = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Initialize a new cdk-factory project
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
target_dir: Directory to initialize (e.g., devops/cdk-iac)
|
|
40
|
+
workload_name: Name of the workload (optional)
|
|
41
|
+
environment: Environment name (optional)
|
|
42
|
+
"""
|
|
43
|
+
target_path = Path(target_dir).resolve()
|
|
44
|
+
|
|
45
|
+
if not target_path.exists():
|
|
46
|
+
target_path.mkdir(parents=True, exist_ok=True)
|
|
47
|
+
print(f"✅ Created directory: {target_path}")
|
|
48
|
+
|
|
49
|
+
# Copy app.py template
|
|
50
|
+
app_template = self.templates_dir / "app.py.template"
|
|
51
|
+
app_dest = target_path / "app.py"
|
|
52
|
+
|
|
53
|
+
if app_dest.exists():
|
|
54
|
+
response = input(f"⚠️ {app_dest} already exists. Overwrite? (y/N): ")
|
|
55
|
+
if response.lower() != 'y':
|
|
56
|
+
print("Skipped app.py")
|
|
57
|
+
else:
|
|
58
|
+
shutil.copy(app_template, app_dest)
|
|
59
|
+
print(f"✅ Created {app_dest}")
|
|
60
|
+
else:
|
|
61
|
+
shutil.copy(app_template, app_dest)
|
|
62
|
+
print(f"✅ Created {app_dest}")
|
|
63
|
+
|
|
64
|
+
# Copy cdk.json template
|
|
65
|
+
cdk_json_template = self.templates_dir / "cdk.json.template"
|
|
66
|
+
cdk_json_dest = target_path / "cdk.json"
|
|
67
|
+
|
|
68
|
+
if cdk_json_dest.exists():
|
|
69
|
+
print(f"⚠️ {cdk_json_dest} already exists. Skipping.")
|
|
70
|
+
else:
|
|
71
|
+
shutil.copy(cdk_json_template, cdk_json_dest)
|
|
72
|
+
print(f"✅ Created {cdk_json_dest}")
|
|
73
|
+
|
|
74
|
+
# Create minimal config.json
|
|
75
|
+
config_dest = target_path / "config.json"
|
|
76
|
+
if config_dest.exists():
|
|
77
|
+
print(f"⚠️ {config_dest} already exists. Skipping.")
|
|
78
|
+
else:
|
|
79
|
+
self._create_minimal_config(
|
|
80
|
+
config_dest,
|
|
81
|
+
workload_name=workload_name,
|
|
82
|
+
environment=environment
|
|
83
|
+
)
|
|
84
|
+
print(f"✅ Created {config_dest}")
|
|
85
|
+
|
|
86
|
+
# Create .gitignore
|
|
87
|
+
gitignore_dest = target_path / ".gitignore"
|
|
88
|
+
if not gitignore_dest.exists():
|
|
89
|
+
gitignore_dest.write_text("cdk.out/\n*.swp\n.DS_Store\n__pycache__/\n")
|
|
90
|
+
print(f"✅ Created {gitignore_dest}")
|
|
91
|
+
|
|
92
|
+
print("\n✨ Project initialized successfully!")
|
|
93
|
+
print(f"\nNext steps:")
|
|
94
|
+
print(f"1. cd {target_path}")
|
|
95
|
+
print(f"2. Edit config.json to configure your infrastructure")
|
|
96
|
+
print(f"3. Run: cdk synth")
|
|
97
|
+
print(f"4. Run: cdk deploy")
|
|
98
|
+
|
|
99
|
+
def _create_minimal_config(
|
|
100
|
+
self,
|
|
101
|
+
path: Path,
|
|
102
|
+
workload_name: Optional[str] = None,
|
|
103
|
+
environment: Optional[str] = None
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Create a minimal config.json template"""
|
|
106
|
+
config = {
|
|
107
|
+
"cdk": {
|
|
108
|
+
"parameters": [
|
|
109
|
+
{
|
|
110
|
+
"placeholder": "{{ENVIRONMENT}}",
|
|
111
|
+
"env_var_name": "ENVIRONMENT",
|
|
112
|
+
"cdk_parameter_name": "Environment"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"placeholder": "{{WORKLOAD_NAME}}",
|
|
116
|
+
"env_var_name": "WORKLOAD_NAME",
|
|
117
|
+
"cdk_parameter_name": "WorkloadName"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"placeholder": "{{AWS_ACCOUNT}}",
|
|
121
|
+
"env_var_name": "AWS_ACCOUNT",
|
|
122
|
+
"cdk_parameter_name": "AccountNumber"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"placeholder": "{{AWS_REGION}}",
|
|
126
|
+
"env_var_name": "AWS_REGION",
|
|
127
|
+
"cdk_parameter_name": "AccountRegion"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"workload": {
|
|
132
|
+
"name": workload_name or "{{WORKLOAD_NAME}}",
|
|
133
|
+
"environment": environment or "{{ENVIRONMENT}}",
|
|
134
|
+
"deployments": []
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
import json
|
|
139
|
+
path.write_text(json.dumps(config, indent=2))
|
|
140
|
+
|
|
141
|
+
def list_templates(self) -> None:
|
|
142
|
+
"""List available templates"""
|
|
143
|
+
print("Available templates:")
|
|
144
|
+
if self.templates_dir.exists():
|
|
145
|
+
for template in self.templates_dir.glob("*.template"):
|
|
146
|
+
print(f" - {template.name}")
|
|
147
|
+
else:
|
|
148
|
+
print(" No templates found")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def main():
|
|
152
|
+
"""CLI entry point"""
|
|
153
|
+
parser = argparse.ArgumentParser(
|
|
154
|
+
description="CDK Factory CLI - Initialize and manage cdk-factory projects"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
158
|
+
|
|
159
|
+
# Init command
|
|
160
|
+
init_parser = subparsers.add_parser(
|
|
161
|
+
"init",
|
|
162
|
+
help="Initialize a new cdk-factory project"
|
|
163
|
+
)
|
|
164
|
+
init_parser.add_argument(
|
|
165
|
+
"directory",
|
|
166
|
+
help="Target directory (e.g., devops/cdk-iac)"
|
|
167
|
+
)
|
|
168
|
+
init_parser.add_argument(
|
|
169
|
+
"--workload-name",
|
|
170
|
+
help="Workload name"
|
|
171
|
+
)
|
|
172
|
+
init_parser.add_argument(
|
|
173
|
+
"--environment",
|
|
174
|
+
help="Environment (dev, prod, etc.)"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
# List templates command
|
|
178
|
+
subparsers.add_parser(
|
|
179
|
+
"list-templates",
|
|
180
|
+
help="List available templates"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
args = parser.parse_args()
|
|
184
|
+
|
|
185
|
+
cli = CdkFactoryCLI()
|
|
186
|
+
|
|
187
|
+
if args.command == "init":
|
|
188
|
+
cli.init_project(
|
|
189
|
+
args.directory,
|
|
190
|
+
workload_name=args.workload_name,
|
|
191
|
+
environment=args.environment
|
|
192
|
+
)
|
|
193
|
+
elif args.command == "list-templates":
|
|
194
|
+
cli.list_templates()
|
|
195
|
+
else:
|
|
196
|
+
parser.print_help()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if __name__ == "__main__":
|
|
200
|
+
main()
|
|
@@ -3,6 +3,7 @@ Geek Cafe Pipeline
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
from typing import List, Dict, Any
|
|
7
8
|
|
|
8
9
|
import aws_cdk as cdk
|
|
@@ -359,9 +360,17 @@ class PipelineFactoryStack(cdk.Stack):
|
|
|
359
360
|
build_commands = self._get_build_commands()
|
|
360
361
|
|
|
361
362
|
cdk_out_directory = self.workload.output_directory
|
|
363
|
+
|
|
364
|
+
# CdkAppFactory already provides the correct path:
|
|
365
|
+
# - For pipelines: relative path (e.g., "../../cdk.out" or "cdk.out")
|
|
366
|
+
# - For local: absolute path (but this code only runs for pipelines)
|
|
367
|
+
# If somehow we get an absolute path, convert it to just the basename
|
|
368
|
+
if cdk_out_directory and os.path.isabs(cdk_out_directory):
|
|
369
|
+
# Fallback: just use the last component
|
|
370
|
+
cdk_out_directory = os.path.basename(cdk_out_directory)
|
|
362
371
|
|
|
363
372
|
build_commands.append(f"echo 👉 cdk_directory: {cdk_directory}")
|
|
364
|
-
build_commands.append(f"echo 👉 cdk_out_directory: {cdk_out_directory}")
|
|
373
|
+
build_commands.append(f"echo 👉 cdk_out_directory (relative): {cdk_out_directory}")
|
|
365
374
|
build_commands.append("echo 👉 PWD from synth shell step: ${PWD}")
|
|
366
375
|
|
|
367
376
|
shell = pipelines.ShellStep(
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# CDK Factory Templates
|
|
2
|
+
|
|
3
|
+
This directory contains templates for initializing new cdk-factory projects.
|
|
4
|
+
|
|
5
|
+
## Available Templates
|
|
6
|
+
|
|
7
|
+
- **`app.py.template`** - Standard application entry point
|
|
8
|
+
- **`cdk.json.template`** - CDK configuration file
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Method 1: Using the CLI (Recommended)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Install cdk-factory with CLI support
|
|
16
|
+
pip install cdk-factory
|
|
17
|
+
|
|
18
|
+
# Initialize a new project
|
|
19
|
+
cdk-factory init devops/cdk-iac --workload-name my-app --environment dev
|
|
20
|
+
|
|
21
|
+
# This creates:
|
|
22
|
+
# - devops/cdk-iac/app.py
|
|
23
|
+
# - devops/cdk-iac/cdk.json
|
|
24
|
+
# - devops/cdk-iac/config.json (minimal template)
|
|
25
|
+
# - devops/cdk-iac/.gitignore
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Method 2: Manual Copy
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Copy templates manually
|
|
32
|
+
cp templates/app.py.template your-project/devops/cdk-iac/app.py
|
|
33
|
+
cp templates/cdk.json.template your-project/devops/cdk-iac/cdk.json
|
|
34
|
+
|
|
35
|
+
# Create config.json (see examples/)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Template Variables
|
|
39
|
+
|
|
40
|
+
The templates use minimal configuration. All settings are driven by:
|
|
41
|
+
|
|
42
|
+
1. **Environment Variables** - `AWS_ACCOUNT`, `AWS_REGION`, `WORKLOAD_NAME`, etc.
|
|
43
|
+
2. **CDK Context** - Pass via `-c` flag: `cdk deploy -c WorkloadName=my-app`
|
|
44
|
+
3. **config.json** - Your infrastructure configuration
|
|
45
|
+
|
|
46
|
+
## Project Structure
|
|
47
|
+
|
|
48
|
+
After initialization, your project should look like:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
your-project/
|
|
52
|
+
├── devops/
|
|
53
|
+
│ └── cdk-iac/
|
|
54
|
+
│ ├── app.py # Entry point (from template)
|
|
55
|
+
│ ├── cdk.json # CDK config (from template)
|
|
56
|
+
│ ├── config.json # Your infrastructure config
|
|
57
|
+
│ ├── .gitignore # Generated
|
|
58
|
+
│ └── commands/ # Your build scripts (optional)
|
|
59
|
+
│ ├── docker-build.sh
|
|
60
|
+
│ └── docker-build.py
|
|
61
|
+
├── src/ # Your application code
|
|
62
|
+
└── Dockerfile # Your docker config
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Customization
|
|
66
|
+
|
|
67
|
+
The templates are intentionally minimal. You can:
|
|
68
|
+
|
|
69
|
+
1. ✅ Add custom environment variables
|
|
70
|
+
2. ✅ Modify config.json structure
|
|
71
|
+
3. ✅ Add project-specific initialization in app.py
|
|
72
|
+
4. ❌ Don't modify core path resolution logic (it's environment-agnostic)
|
|
73
|
+
|
|
74
|
+
## Integration with pyproject.toml
|
|
75
|
+
|
|
76
|
+
To enable the CLI, update `pyproject.toml`:
|
|
77
|
+
|
|
78
|
+
```toml
|
|
79
|
+
[project.scripts]
|
|
80
|
+
cdk-factory = "cdk_factory.cli:main"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or in `setup.py`:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
entry_points={
|
|
87
|
+
'console_scripts': [
|
|
88
|
+
'cdk-factory=cdk_factory.cli:main',
|
|
89
|
+
],
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Benefits
|
|
94
|
+
|
|
95
|
+
✅ **No boilerplate** - Standard entry point across all projects
|
|
96
|
+
✅ **Environment-agnostic** - Works locally and in CI/CD
|
|
97
|
+
✅ **Consistent** - All projects follow same pattern
|
|
98
|
+
✅ **Maintainable** - Updates to template benefit all projects
|
|
99
|
+
✅ **Simple** - Just 30 lines of code in app.py
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CDK Factory Application Entry Point
|
|
4
|
+
|
|
5
|
+
This is the standard entry point for any cdk-factory based project.
|
|
6
|
+
All configuration is driven by environment variables and CDK context.
|
|
7
|
+
|
|
8
|
+
To use this template:
|
|
9
|
+
1. Copy to your project's CDK directory (e.g., devops/cdk-iac/app.py)
|
|
10
|
+
2. Update cdk.json to reference this file: "app": "python app.py"
|
|
11
|
+
3. Create your config.json
|
|
12
|
+
4. Run: cdk synth
|
|
13
|
+
|
|
14
|
+
Note: cdk.out is automatically placed at project root for CodeBuild compatibility.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from cdk_factory.app import CdkAppFactory
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
# Runtime directory (where this file lives)
|
|
24
|
+
runtime_dir = str(Path(__file__).parent.resolve())
|
|
25
|
+
|
|
26
|
+
# Configuration (Priority: ENV > CDK Context > default)
|
|
27
|
+
config_path = os.getenv('CDK_CONFIG_PATH', 'config.json')
|
|
28
|
+
|
|
29
|
+
# Create and synth
|
|
30
|
+
# outdir is automatically set to project_root/cdk.out
|
|
31
|
+
factory = CdkAppFactory(
|
|
32
|
+
config_path=config_path,
|
|
33
|
+
runtime_directory=runtime_dir
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
factory.synth(cdk_app_file=__file__)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": "python app.py",
|
|
3
|
+
"watch": {
|
|
4
|
+
"include": [
|
|
5
|
+
"**"
|
|
6
|
+
],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"README.md",
|
|
9
|
+
"cdk*.json",
|
|
10
|
+
"requirements*.txt",
|
|
11
|
+
"source.bat",
|
|
12
|
+
"**/__init__.py",
|
|
13
|
+
"**/__pycache__",
|
|
14
|
+
"**/.pytest_cache",
|
|
15
|
+
".git",
|
|
16
|
+
".venv"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"context": {
|
|
20
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
21
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
22
|
+
"@aws-cdk/core:target-partitions": [
|
|
23
|
+
"aws",
|
|
24
|
+
"aws-cn"
|
|
25
|
+
],
|
|
26
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
27
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
28
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
29
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
30
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
31
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
32
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
33
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
34
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
35
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
36
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
37
|
+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
|
|
38
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
39
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
40
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
41
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
42
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
43
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
44
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
45
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
46
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
47
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
48
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
49
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
50
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
51
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
52
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
53
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
54
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
55
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
56
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
57
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
58
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
59
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
60
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
61
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
62
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
63
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
64
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
65
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
66
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
67
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
68
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
69
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
70
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
|
|
71
|
+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.9.0"
|