cdk-factory 0.7.30__tar.gz → 0.8.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.

Files changed (139) hide show
  1. cdk_factory-0.8.0/.windsurfrules +268 -0
  2. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/PKG-INFO +1 -1
  3. cdk_factory-0.8.0/examples/separate-api-gateway/README.md +94 -0
  4. cdk_factory-0.8.0/examples/separate-api-gateway/api-gateway-stack.json +83 -0
  5. cdk_factory-0.8.0/examples/separate-api-gateway/config.json +74 -0
  6. cdk_factory-0.8.0/examples/separate-api-gateway/lambda-stack.json +62 -0
  7. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/pyproject.toml +1 -1
  8. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/pysetup.py +675 -432
  9. cdk_factory-0.8.0/run-tests-clean-venv.sh +57 -0
  10. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/run-tests.sh +6 -23
  11. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/cdk_config.py +7 -4
  12. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/enhanced_base_config.py +9 -4
  13. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/enhanced_ssm_config.py +9 -6
  14. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py +63 -3
  15. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/api_gateway/api_gateway_stack.py +104 -2
  16. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/aws_lambdas/lambda_stack.py +121 -75
  17. cdk_factory-0.8.0/src/cdk_factory/version.py +1 -0
  18. cdk_factory-0.7.30/src/cdk_factory/version.py +0 -1
  19. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/.gitignore +0 -0
  20. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/LICENSE +0 -0
  21. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/README.md +0 -0
  22. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/archive/README.md +0 -0
  23. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/archive/migrate_to_enhanced_ssm.py +0 -0
  24. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/mypy.ini +0 -0
  25. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/publish_to_pypi.py +0 -0
  26. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/publish_to_pypi.sh +0 -0
  27. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/pysetup.sh +0 -0
  28. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/requirements.dev.txt +0 -0
  29. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/requirements.tests.txt +0 -0
  30. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/requirements.txt +0 -0
  31. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/run-checks.sh +0 -0
  32. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/__init__.py +0 -0
  33. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/app.py +0 -0
  34. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/builds/README.md +0 -0
  35. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/cdk.json +0 -0
  36. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/commands/command_loader.py +0 -0
  37. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/base_config.py +0 -0
  38. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/deployment.py +0 -0
  39. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/deployment_wave.py +0 -0
  40. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/devops.py +0 -0
  41. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/management.py +0 -0
  42. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/pipeline.py +0 -0
  43. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/pipeline_stage.py +0 -0
  44. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/_resources.py +0 -0
  45. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/api_gateway.py +0 -0
  46. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/apigateway_route_config.py +0 -0
  47. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/auto_scaling.py +0 -0
  48. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/cloudfront.py +0 -0
  49. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/cloudwatch_widget.py +0 -0
  50. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/code_artifact.py +0 -0
  51. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/code_artifact_login.py +0 -0
  52. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/code_repository.py +0 -0
  53. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/cognito.py +0 -0
  54. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/docker.py +0 -0
  55. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/dynamodb.py +0 -0
  56. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/ecr.py +0 -0
  57. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/exisiting.py +0 -0
  58. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/lambda_function.py +0 -0
  59. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/lambda_layers.py +0 -0
  60. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/lambda_triggers.py +0 -0
  61. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/load_balancer.py +0 -0
  62. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/rds.py +0 -0
  63. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/resource_mapping.py +0 -0
  64. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/resource_naming.py +0 -0
  65. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/resource_types.py +0 -0
  66. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/route53.py +0 -0
  67. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/route53_hosted_zone.py +0 -0
  68. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/rum.py +0 -0
  69. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/s3.py +0 -0
  70. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/security_group.py +0 -0
  71. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/security_group_full_stack.py +0 -0
  72. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/sqs.py +0 -0
  73. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/resources/vpc.py +0 -0
  74. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/stack.py +0 -0
  75. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/configurations/workload.py +0 -0
  76. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/ecr/ecr_construct.py +0 -0
  77. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/lambdas/lambda_function_construct.py +0 -0
  78. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/lambdas/lambda_function_docker_construct.py +0 -0
  79. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/lambdas/lambda_function_role_construct.py +0 -0
  80. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/lambdas/policies/policy_docs.py +0 -0
  81. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/lambdas/policies/policy_statements.py +0 -0
  82. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_construct.py +0 -0
  83. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_destination_construct.py +0 -0
  84. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_source_construct.py +0 -0
  85. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/constructs/sqs/policies/sqs_policies.py +0 -0
  86. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/interfaces/enhanced_ssm_parameter_mixin.py +0 -0
  87. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/interfaces/istack.py +0 -0
  88. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/interfaces/live_ssm_resolver.py +0 -0
  89. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/interfaces/ssm_parameter_mixin.py +0 -0
  90. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/lambdas/health_handler.py +0 -0
  91. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/pipeline/pipeline_factory.py +0 -0
  92. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/pipeline/security/policies.py +0 -0
  93. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/pipeline/security/roles.py +0 -0
  94. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/pipeline/stage.py +0 -0
  95. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack/istack.py +0 -0
  96. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack/stack_factory.py +0 -0
  97. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack/stack_module_loader.py +0 -0
  98. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack/stack_module_registry.py +0 -0
  99. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack/stack_modules.py +0 -0
  100. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/__init__.py +0 -0
  101. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/auto_scaling/__init__.py +0 -0
  102. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py +0 -0
  103. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/buckets/README.md +0 -0
  104. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/buckets/bucket_stack.py +0 -0
  105. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/code_artifact/code_artifact_stack.py +0 -0
  106. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/cognito/cognito_stack.py +0 -0
  107. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/dynamodb/dynamodb_stack.py +0 -0
  108. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/ecr/README.md +0 -0
  109. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/ecr/ecr_stack.py +0 -0
  110. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/load_balancer/__init__.py +0 -0
  111. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/load_balancer/load_balancer_stack.py +0 -0
  112. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/rds/__init__.py +0 -0
  113. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/rds/rds_stack.py +0 -0
  114. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/route53/__init__.py +0 -0
  115. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/route53/route53_stack.py +0 -0
  116. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/rum/__init__.py +0 -0
  117. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/rum/rum_stack.py +0 -0
  118. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/security_group/__init__.py +0 -0
  119. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/security_group/security_group_full_stack.py +0 -0
  120. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/security_group/security_group_stack.py +0 -0
  121. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/simple_queue_service/sqs_stack.py +0 -0
  122. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/stack_base.py +0 -0
  123. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/vpc/__init__.py +0 -0
  124. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/vpc/vpc_stack.py +0 -0
  125. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stack_library/websites/static_website_stack.py +0 -0
  126. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/stages/websites/static_website_stage.py +0 -0
  127. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/api_gateway_integration_utility.py +0 -0
  128. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/commandline_args.py +0 -0
  129. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/configuration_loader.py +0 -0
  130. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/docker_utilities.py +0 -0
  131. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/environment_services.py +0 -0
  132. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/file_operations.py +0 -0
  133. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/git_utilities.py +0 -0
  134. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/json_loading_utility.py +0 -0
  135. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/lambda_function_utilities.py +0 -0
  136. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utilities/os_execute.py +0 -0
  137. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/utils/api_gateway_utilities.py +0 -0
  138. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/cdk_factory/workload/workload_factory.py +0 -0
  139. {cdk_factory-0.7.30 → cdk_factory-0.8.0}/src/handlers/test/handler.py +0 -0
@@ -0,0 +1,268 @@
1
+ # CDK Factory - Development Rules & Guidelines
2
+
3
+ ## Project Type: AWS CDK Infrastructure Framework
4
+
5
+ This is a reusable AWS CDK framework for building cloud infrastructure with standardized patterns.
6
+
7
+ ## Architecture Principles
8
+
9
+ ### Stack Separation Pattern (v2.0+)
10
+ - **Lambda Stack**: Creates Lambda functions ONLY, exports ARNs to SSM
11
+ - **API Gateway Stack**: Imports Lambda ARNs from SSM, creates API Gateway
12
+ - **No direct cross-stack references**: Use SSM Parameter Store for loose coupling
13
+ - **Reason**: Enables independent deployments, avoids circular dependencies, follows AWS best practices
14
+
15
+ ### SSM-Based Cross-Stack Communication
16
+ ```python
17
+ # Lambda Stack Exports
18
+ /{organization}/{environment}/lambda/{lambda-name}/arn
19
+ /{organization}/{environment}/lambda/{lambda-name}/function-name
20
+
21
+ # API Gateway Imports
22
+ # Auto-discovery via lambda_name
23
+ {"lambda_name": "my-function"} # Finds /org/env/lambda/my-function/arn
24
+
25
+ # Explicit path
26
+ {"lambda_arn_ssm_path": "/custom/path/arn"}
27
+ ```
28
+
29
+ ## Code Style & Standards
30
+
31
+ ### Python Standards
32
+ - **Style**: PEP 8 compliant, use `black` for formatting
33
+ - **Type Hints**: Use type annotations for all function signatures
34
+ - **Imports**: Absolute imports from `cdk_factory`, group stdlib/third-party/local
35
+ - **Docstrings**: Google-style docstrings for all public methods
36
+
37
+ ### CDK Patterns
38
+ - Use L2 constructs when available, fall back to L1 only when necessary
39
+ - Always validate configurations before creating resources
40
+ - Provide clear error messages with migration guidance for breaking changes
41
+ - Export important resource identifiers to SSM when `ssm.enabled: true`
42
+
43
+ ## Testing Requirements
44
+
45
+ ### Test Structure
46
+ - **Unit Tests**: `tests/unit/` - Test individual components
47
+ - **Integration Tests**: `tests/integration/` - Test multi-stack scenarios
48
+ - **Use Fixtures**: Pytest fixtures for common test setup
49
+ - **No Mocking CDK**: Test real CDK synthesis, not mocked behavior
50
+
51
+ ### Running Tests
52
+ ```bash
53
+ ./run-tests.sh # Creates fresh venv, runs all tests
54
+ pytest tests/unit/test_lambda_stack.py -v # Specific test file
55
+ ```
56
+
57
+ ### Test Patterns
58
+ ```python
59
+ from aws_cdk.assertions import Template
60
+
61
+ def test_stack_creation(app, deployment_config, workload_config):
62
+ stack = MyStack(app, "TestStack")
63
+ stack.build(config, deployment_config, workload_config)
64
+
65
+ template = Template.from_stack(stack)
66
+ template.has_resource("AWS::Lambda::Function", {...})
67
+ ```
68
+
69
+ ## Configuration Patterns
70
+
71
+ ### Workload Config Structure
72
+ ```json
73
+ {
74
+ "workload": {
75
+ "name": "my-app",
76
+ "devops": {"ci_cd": {"enabled": true}},
77
+ "stacks": [
78
+ {
79
+ "name": "lambda-stack",
80
+ "module": "lambda_stack",
81
+ "ssm": {
82
+ "enabled": true,
83
+ "organization": "my-app",
84
+ "environment": "prod"
85
+ },
86
+ "resources": [...]
87
+ },
88
+ {
89
+ "name": "api-stack",
90
+ "module": "api_gateway_stack",
91
+ "api_gateway": {
92
+ "ssm": {
93
+ "imports": {
94
+ "organization": "my-app",
95
+ "environment": "prod"
96
+ }
97
+ },
98
+ "routes": [
99
+ {"path": "/api", "lambda_name": "my-function"}
100
+ ]
101
+ }
102
+ }
103
+ ]
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Deprecation & Migration Strategy
109
+
110
+ ### When Deprecating Features
111
+ 1. **Detect deprecated patterns** in config validation
112
+ 2. **Raise helpful errors** with clear migration instructions
113
+ 3. **Reference documentation**: Point to `docs/MIGRATION_V2.md`
114
+ 4. **Show examples**: Include before/after config snippets
115
+ 5. **Update tests**: Expect `ValueError` for deprecated patterns
116
+
117
+ ### Error Message Format
118
+ ```python
119
+ error_msg = """
120
+ ╔══════════════════════════════════════════════════════════════════════════════╗
121
+ ║ 🚨 DEPRECATED CONFIGURATION DETECTED ║
122
+ ╚══════════════════════════════════════════════════════════════════════════════╝
123
+
124
+ Your configuration uses deprecated pattern X, which caused issues Y.
125
+
126
+ 🔧 REQUIRED MIGRATION:
127
+ 1. Remove deprecated field
128
+ 2. Add new pattern
129
+ 3. Update pipeline order
130
+
131
+ 📚 MIGRATION GUIDE:
132
+ https://github.com/org/cdk-factory/blob/main/docs/MIGRATION_V2.md
133
+
134
+ 💡 EXAMPLES:
135
+ See: examples/separate-api-gateway/
136
+ """
137
+ ```
138
+
139
+ ## Documentation Standards
140
+
141
+ ### Required Documentation
142
+ - **README.md**: Overview, quickstart, installation
143
+ - **docs/MIGRATION_V2.md**: Breaking changes migration guide
144
+ - **examples/**: Working examples for each major pattern
145
+ - **Inline Comments**: Explain "why" not "what"
146
+
147
+ ### Example Structure
148
+ ```
149
+ examples/
150
+ separate-api-gateway/
151
+ lambda-stack.json # Lambda config
152
+ api-gateway-stack.json # API Gateway config
153
+ README.md # Explanation
154
+ ```
155
+
156
+ ## Common Patterns
157
+
158
+ ### Lambda Function Creation
159
+ ```python
160
+ # Always use utility for consistent patterns
161
+ from cdk_factory.utilities.lambda_function_utilities import LambdaFunctionUtility
162
+
163
+ lambda_fn = LambdaFunctionUtility.create_function(
164
+ self, config, deployment, workload
165
+ )
166
+
167
+ # Export to SSM if enabled
168
+ if ssm_enabled:
169
+ self._export_lambda_to_ssm(lambda_fn, config)
170
+ ```
171
+
172
+ ### API Gateway Lambda Integration
173
+ ```python
174
+ # Import from SSM (auto-discovery)
175
+ lambda_arn = self._get_lambda_arn_from_ssm(lambda_name)
176
+
177
+ # OR explicit path
178
+ lambda_arn = self._get_lambda_arn_from_explicit_path(ssm_path)
179
+
180
+ # OR legacy inline creation (backward compatibility)
181
+ lambda_fn = self._create_inline_lambda(route_config)
182
+ ```
183
+
184
+ ## Error Handling
185
+
186
+ ### Validation Before Resource Creation
187
+ ```python
188
+ def build(self, stack_config, deployment, workload):
189
+ # 1. Check for deprecated patterns
190
+ self._check_for_deprecated_config(stack_config)
191
+
192
+ # 2. Validate required fields
193
+ self._validate_config(stack_config)
194
+
195
+ # 3. Create resources
196
+ self._create_resources(stack_config)
197
+ ```
198
+
199
+ ### Clear Error Messages
200
+ - Use emoji for visibility: 🚨 ❌ ✅ 💡 📚
201
+ - Provide actionable solutions
202
+ - Include relevant config snippet
203
+ - Reference documentation
204
+
205
+ ## Git Workflow
206
+
207
+ ### Branch Strategy
208
+ - `main`: Production-ready code
209
+ - `develop`: Integration branch
210
+ - `feature/*`: New features
211
+ - `fix/*`: Bug fixes
212
+ - `docs/*`: Documentation updates
213
+
214
+ ### Commit Messages
215
+ ```
216
+ feat: Add SSM-based Lambda import for API Gateway
217
+ fix: Correct deprecation detection for api_gateway config
218
+ docs: Add migration guide for v2.0 breaking changes
219
+ test: Update tests for separated stack pattern
220
+ ```
221
+
222
+ ## Dependencies
223
+
224
+ ### Production
225
+ - `aws-cdk-lib`: AWS CDK v2
226
+ - `constructs`: CDK constructs
227
+ - Python 3.11+
228
+
229
+ ### Development
230
+ - `pytest`: Testing framework
231
+ - `black`: Code formatting
232
+ - `mypy`: Type checking
233
+ - `aws-cdk.assertions`: CDK testing utilities
234
+
235
+ ## Performance Considerations
236
+
237
+ - Minimize SSM parameter lookups (cache when possible)
238
+ - Use batch operations for multiple resources
239
+ - Avoid synthesizing stacks in tests unless necessary
240
+ - Keep Lambda packages small (use layers for common deps)
241
+
242
+ ## Security Best Practices
243
+
244
+ - Never hardcode credentials or API keys
245
+ - Use SSM Parameter Store for sensitive values
246
+ - Apply least-privilege IAM policies
247
+ - Enable encryption for S3 buckets and DynamoDB tables
248
+ - Validate all user input before creating resources
249
+
250
+ ## Monitoring & Observability
251
+
252
+ - Export important metrics to CloudWatch
253
+ - Use Lambda Powertools for structured logging
254
+ - Create CloudWatch alarms for critical resources
255
+ - Tag all resources with environment, workload, and purpose
256
+
257
+ ## When to Create New Stack Types
258
+
259
+ Create a new stack module when:
260
+ 1. Resource type requires unique deployment patterns
261
+ 2. Cross-stack dependencies are minimal
262
+ 3. Reusability across projects is high
263
+ 4. Testing can be isolated
264
+
265
+ Don't create a new stack for:
266
+ 1. Single-purpose resources (use existing stack)
267
+ 2. Tightly coupled resources (keep in same stack)
268
+ 3. Rarely used patterns (extend existing stack)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk_factory
3
- Version: 0.7.30
3
+ Version: 0.8.0
4
4
  Summary: CDK Factory. A QuickStarter and best practices setup for CDK projects
5
5
  Author-email: Eric Wilson <eric.wilson@geekcafe.com>
6
6
  License: MIT License
@@ -0,0 +1,94 @@
1
+ # Example: Separate Lambda and API Gateway Stacks
2
+
3
+ This example demonstrates the **recommended pattern** for deploying Lambda functions and API Gateway separately using CDK-Factory v2.0+.
4
+
5
+ ## Architecture
6
+
7
+ ```
8
+ ┌─────────────────────────────────────────────────────────────┐
9
+ │ Pipeline Stage 1 │
10
+ │ Deploy Lambda Stacks │
11
+ ├─────────────────────────────────────────────────────────────┤
12
+ │ │
13
+ │ Lambda Stack │
14
+ │ ┌───────────────────────────────────────────────┐ │
15
+ │ │ Create Lambda Functions │ │
16
+ │ │ ├─ Health Check Lambda │ │
17
+ │ │ ├─ User API Lambda │ │
18
+ │ │ └─ Admin API Lambda │ │
19
+ │ │ │ │
20
+ │ │ Export to SSM Parameter Store: │ │
21
+ │ │ ├─ /org/env/lambda/health/arn │ │
22
+ │ │ ├─ /org/env/lambda/user-api/arn │ │
23
+ │ │ └─ /org/env/lambda/admin-api/arn │ │
24
+ │ └───────────────────────────────────────────────┘ │
25
+ │ │ │
26
+ │ │ SSM Parameters │
27
+ │ ▼ │
28
+ └─────────────────────────────────────────────────────────────┘
29
+
30
+ ┌─────────────────────────────────────────────────────────────┐
31
+ │ Pipeline Stage 2 │
32
+ │ Deploy API Gateway Stack │
33
+ ├─────────────────────────────────────────────────────────────┤
34
+ │ │
35
+ │ API Gateway Stack │
36
+ │ ┌───────────────────────────────────────────────┐ │
37
+ │ │ Import Lambda ARNs from SSM │ │
38
+ │ │ ├─ GET /health → health Lambda │ │
39
+ │ │ ├─ GET /users → user-api Lambda │ │
40
+ │ │ ├─ POST /users → user-api Lambda │ │
41
+ │ │ └─ GET /admin/stats → admin-api Lambda │ │
42
+ │ │ │ │
43
+ │ │ Create API Gateway │ │
44
+ │ │ ├─ Stage: prod │ │
45
+ │ │ ├─ CORS Configuration │ │
46
+ │ │ ├─ Cognito Authorizer (optional) │ │
47
+ │ │ └─ Custom Domain (optional) │ │
48
+ │ └───────────────────────────────────────────────┘ │
49
+ │ │
50
+ └─────────────────────────────────────────────────────────────┘
51
+ ```
52
+
53
+ ## Files
54
+
55
+ - `lambda-stack.json` - Lambda function definitions
56
+ - `api-gateway-stack.json` - API Gateway with route configurations
57
+ - `config.json` - Pipeline configuration
58
+
59
+ ## Usage
60
+
61
+ 1. **Deploy Lambda Stack First:**
62
+ ```bash
63
+ cdk deploy MyApp-Lambda-Stack
64
+ ```
65
+
66
+ 2. **Verify SSM Parameters:**
67
+ ```bash
68
+ aws ssm get-parameter --name /my-app/prod/lambda/health-check/arn
69
+ ```
70
+
71
+ 3. **Deploy API Gateway Stack:**
72
+ ```bash
73
+ cdk deploy MyApp-API-Gateway-Stack
74
+ ```
75
+
76
+ ## Key Features
77
+
78
+ ✅ **SSM-based Cross-Stack Communication** - No CloudFormation exports
79
+ ✅ **Independent Lifecycles** - Update Lambdas without touching API Gateway
80
+ ✅ **Auto-Discovery** - Reference Lambdas by name, ARN auto-resolved
81
+ ✅ **Multiple Environments** - Easy to deploy dev/staging/prod
82
+ ✅ **Security Best Practices** - Cognito integration, CORS, authorization
83
+
84
+ ## Testing
85
+
86
+ Test Lambda independently:
87
+ ```bash
88
+ aws lambda invoke --function-name my-lambda output.json
89
+ ```
90
+
91
+ Test API Gateway:
92
+ ```bash
93
+ curl https://api-id.execute-api.region.amazonaws.com/prod/health
94
+ ```
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-api-gateway",
3
+ "module": "api_gateway_stack",
4
+ "enabled": true,
5
+ "api_gateway": {
6
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-api",
7
+ "description": "API Gateway for {{WORKLOAD_NAME}} application",
8
+ "api_type": "REST",
9
+ "stage_name": "prod",
10
+ "ssm": {
11
+ "enabled": true,
12
+ "workload": "{{WORKLOAD_NAME}}",
13
+ "environment": "{{ENVIRONMENT}}",
14
+ "exports": {
15
+ "enabled": true
16
+ },
17
+ "imports": {
18
+ "workload": "{{WORKLOAD_NAME}}",
19
+ "environment": "{{ENVIRONMENT}}"
20
+ }
21
+ },
22
+ "deploy_options": {
23
+ "data_trace_enabled": false,
24
+ "metrics_enabled": true,
25
+ "tracing_enabled": true,
26
+ "throttling_rate_limit": 1000,
27
+ "throttling_burst_limit": 2000
28
+ },
29
+ "cognito_authorizer": {
30
+ "enabled": false,
31
+ "user_pool_arn": "{{COGNITO_USER_POOL_ARN}}"
32
+ },
33
+ "routes": [
34
+ {
35
+ "path": "/health",
36
+ "method": "GET",
37
+ "lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-health-check",
38
+ "authorization_type": "NONE",
39
+ "allow_public_override": true,
40
+ "cors": {
41
+ "origins": ["*"],
42
+ "methods": ["GET", "OPTIONS"],
43
+ "headers": ["Content-Type", "Authorization"]
44
+ }
45
+ },
46
+ {
47
+ "path": "/users",
48
+ "method": "GET",
49
+ "lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-user-api",
50
+ "authorization_type": "NONE",
51
+ "allow_public_override": true,
52
+ "cors": {
53
+ "origins": ["*"],
54
+ "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
55
+ "headers": ["Content-Type", "Authorization"]
56
+ }
57
+ },
58
+ {
59
+ "path": "/users",
60
+ "method": "POST",
61
+ "lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-user-api",
62
+ "authorization_type": "NONE",
63
+ "allow_public_override": true,
64
+ "cors": {
65
+ "origins": ["*"],
66
+ "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
67
+ "headers": ["Content-Type", "Authorization"]
68
+ }
69
+ },
70
+ {
71
+ "path": "/admin/stats",
72
+ "method": "GET",
73
+ "lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-admin-api",
74
+ "authorization_type": "COGNITO",
75
+ "cors": {
76
+ "origins": ["https://admin.example.com"],
77
+ "methods": ["GET", "OPTIONS"],
78
+ "headers": ["Content-Type", "Authorization"]
79
+ }
80
+ }
81
+ ]
82
+ }
83
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "cdk": {
3
+ "parameters": [
4
+ {
5
+ "placeholder": "{{ENVIRONMENT}}",
6
+ "env_var_name": "ENVIRONMENT",
7
+ "cdk_parameter_name": "Environment"
8
+ },
9
+ {
10
+ "placeholder": "{{WORKLOAD_NAME}}",
11
+ "env_var_name": "WORKLOAD_NAME",
12
+ "cdk_parameter_name": "WorkloadName"
13
+ },
14
+ {
15
+ "placeholder": "{{AWS_ACCOUNT}}",
16
+ "env_var_name": "AWS_ACCOUNT",
17
+ "cdk_parameter_name": "AccountNumber"
18
+ },
19
+ {
20
+ "placeholder": "{{AWS_REGION}}",
21
+ "env_var_name": "AWS_REGION",
22
+ "cdk_parameter_name": "AccountRegion"
23
+ },
24
+ {
25
+ "placeholder": "{{DYNAMODB_TABLE_NAME}}",
26
+ "env_var_name": "DYNAMODB_TABLE_NAME",
27
+ "cdk_parameter_name": "DynamoDbTableName"
28
+ },
29
+ {
30
+ "placeholder": "{{COGNITO_USER_POOL_ARN}}",
31
+ "env_var_name": "COGNITO_USER_POOL_ARN",
32
+ "cdk_parameter_name": "CognitoUserPoolArn"
33
+ }
34
+ ]
35
+ },
36
+ "workload": {
37
+ "name": "{{WORKLOAD_NAME}}",
38
+ "description": "Example application with separate Lambda and API Gateway stacks",
39
+ "deployments": [
40
+ {
41
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-pipeline",
42
+ "environment": "{{ENVIRONMENT}}",
43
+ "account": "{{AWS_ACCOUNT}}",
44
+ "region": "{{AWS_REGION}}",
45
+ "mode": "pipeline",
46
+ "pipeline": {
47
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-pipeline",
48
+ "enabled": true,
49
+ "stages": [
50
+ {
51
+ "name": "deploy-lambdas",
52
+ "description": "Deploy Lambda functions and export ARNs to SSM",
53
+ "stacks": [
54
+ {
55
+ "__inherits__": "./lambda-stack.json"
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "name": "deploy-api-gateway",
61
+ "description": "Deploy API Gateway and wire Lambda integrations",
62
+ "stacks": [
63
+ {
64
+ "__inherits__": "./api-gateway-stack.json"
65
+ }
66
+ ]
67
+ }
68
+ ]
69
+ },
70
+ "enabled": true
71
+ }
72
+ ]
73
+ }
74
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-lambdas",
3
+ "module": "lambda_stack",
4
+ "enabled": true,
5
+ "ssm": {
6
+ "enabled": true,
7
+ "workload": "{{WORKLOAD_NAME}}",
8
+ "environment": "{{ENVIRONMENT}}"
9
+ },
10
+ "resources": [
11
+ {
12
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-health-check",
13
+ "src": "./src/handlers/health",
14
+ "handler": "app.lambda_handler",
15
+ "description": "Health check endpoint",
16
+ "runtime": "python3.12",
17
+ "timeout": 10,
18
+ "memory_size": 128,
19
+ "environment_variables": {
20
+ "LOG_LEVEL": "INFO",
21
+ "ENVIRONMENT": "{{ENVIRONMENT}}"
22
+ }
23
+ },
24
+ {
25
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-user-api",
26
+ "src": "./src/handlers/user",
27
+ "handler": "app.lambda_handler",
28
+ "description": "User API operations",
29
+ "runtime": "python3.12",
30
+ "timeout": 30,
31
+ "memory_size": 512,
32
+ "environment_variables": {
33
+ "LOG_LEVEL": "INFO",
34
+ "ENVIRONMENT": "{{ENVIRONMENT}}",
35
+ "TABLE_NAME": "{{DYNAMODB_TABLE_NAME}}"
36
+ },
37
+ "permissions": [
38
+ "dynamodb_read",
39
+ "dynamodb_write"
40
+ ]
41
+ },
42
+ {
43
+ "name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-admin-api",
44
+ "src": "./src/handlers/admin",
45
+ "handler": "app.lambda_handler",
46
+ "description": "Admin API operations",
47
+ "runtime": "python3.12",
48
+ "timeout": 30,
49
+ "memory_size": 512,
50
+ "environment_variables": {
51
+ "LOG_LEVEL": "INFO",
52
+ "ENVIRONMENT": "{{ENVIRONMENT}}",
53
+ "TABLE_NAME": "{{DYNAMODB_TABLE_NAME}}"
54
+ },
55
+ "permissions": [
56
+ "dynamodb_read",
57
+ "dynamodb_write",
58
+ "s3_read"
59
+ ]
60
+ }
61
+ ]
62
+ }
@@ -33,7 +33,7 @@ markers = [
33
33
  [project]
34
34
 
35
35
  name = "cdk_factory"
36
- version = "0.7.30"
36
+ version = "0.8.0"
37
37
  authors = [
38
38
  { name="Eric Wilson", email="eric.wilson@geekcafe.com" }
39
39
  ]