cdk-factory 0.7.31__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cdk-factory might be problematic. Click here for more details.
- cdk_factory-0.8.1/.windsurfrules +268 -0
- cdk_factory-0.8.1/GEEK_CAFE_FIX.md +241 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/PKG-INFO +1 -1
- cdk_factory-0.8.1/examples/separate-api-gateway/README.md +94 -0
- cdk_factory-0.8.1/examples/separate-api-gateway/api-gateway-stack.json +81 -0
- cdk_factory-0.8.1/examples/separate-api-gateway/config.json +74 -0
- cdk_factory-0.8.1/examples/separate-api-gateway/lambda-stack.json +62 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/pyproject.toml +1 -1
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/pysetup.py +675 -432
- cdk_factory-0.8.1/run-tests-clean-venv.sh +57 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/run-tests.sh +6 -23
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/cdk_config.py +7 -4
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/enhanced_base_config.py +9 -4
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/enhanced_ssm_config.py +12 -7
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/api_gateway/api_gateway_stack.py +124 -3
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/aws_lambdas/lambda_stack.py +121 -75
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/api_gateway_integration_utility.py +7 -0
- cdk_factory-0.8.1/src/cdk_factory/version.py +1 -0
- cdk_factory-0.7.31/src/cdk_factory/version.py +0 -1
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/.gitignore +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/LICENSE +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/README.md +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/archive/README.md +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/archive/migrate_to_enhanced_ssm.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/mypy.ini +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/publish_to_pypi.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/publish_to_pypi.sh +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/pysetup.sh +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/requirements.dev.txt +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/requirements.tests.txt +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/requirements.txt +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/run-checks.sh +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/app.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/builds/README.md +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/cdk.json +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/commands/command_loader.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/base_config.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/deployment.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/deployment_wave.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/devops.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/management.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/pipeline.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/pipeline_stage.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/_resources.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/api_gateway.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/apigateway_route_config.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/auto_scaling.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/cloudfront.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/cloudwatch_widget.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/code_artifact.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/code_artifact_login.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/code_repository.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/cognito.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/docker.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/dynamodb.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/ecr.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/exisiting.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/lambda_function.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/lambda_layers.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/lambda_triggers.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/load_balancer.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/rds.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/resource_mapping.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/resource_naming.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/resource_types.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/route53.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/route53_hosted_zone.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/rum.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/s3.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/security_group.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/security_group_full_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/sqs.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/resources/vpc.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/configurations/workload.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/ecr/ecr_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/lambdas/lambda_function_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/lambdas/lambda_function_docker_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/lambdas/lambda_function_role_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/lambdas/policies/policy_docs.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/lambdas/policies/policy_statements.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/s3_buckets/s3_bucket_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_destination_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_source_construct.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/constructs/sqs/policies/sqs_policies.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/interfaces/enhanced_ssm_parameter_mixin.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/interfaces/istack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/interfaces/live_ssm_resolver.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/interfaces/ssm_parameter_mixin.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/lambdas/health_handler.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/pipeline/pipeline_factory.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/pipeline/security/policies.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/pipeline/security/roles.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/pipeline/stage.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack/istack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack/stack_factory.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack/stack_module_loader.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack/stack_module_registry.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack/stack_modules.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/auto_scaling/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/buckets/README.md +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/buckets/bucket_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/code_artifact/code_artifact_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/cognito/cognito_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/dynamodb/dynamodb_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/ecr/README.md +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/ecr/ecr_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/load_balancer/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/load_balancer/load_balancer_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/rds/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/rds/rds_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/route53/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/route53/route53_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/rum/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/rum/rum_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/security_group/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/security_group/security_group_full_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/security_group/security_group_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/simple_queue_service/sqs_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/stack_base.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/vpc/__init__.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/vpc/vpc_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stack_library/websites/static_website_stack.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/stages/websites/static_website_stage.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/commandline_args.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/configuration_loader.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/docker_utilities.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/environment_services.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/file_operations.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/git_utilities.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/json_loading_utility.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/lambda_function_utilities.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utilities/os_execute.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/utils/api_gateway_utilities.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/src/cdk_factory/workload/workload_factory.py +0 -0
- {cdk_factory-0.7.31 → cdk_factory-0.8.1}/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)
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Fix for geek-cafe Cognito Error
|
|
2
|
+
|
|
3
|
+
## The Problem
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
ValueError: User pool ID is required for API Gateway authorizer.
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Your API Gateway stack can't find the Cognito User Pool because the new separated pattern requires **SSM imports** instead of environment variables.
|
|
10
|
+
|
|
11
|
+
## Quick Fix
|
|
12
|
+
|
|
13
|
+
In your `/Users/eric.wilson/Projects/geek-cafe/geek-cafe-web/geek-cafe-lambdas/cdk` config:
|
|
14
|
+
|
|
15
|
+
### Option 1: Add SSM Import (Recommended)
|
|
16
|
+
|
|
17
|
+
**api-gateway-stack.json:**
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"name": "geek-cafe-prod-api-gateway",
|
|
21
|
+
"module": "api_gateway_stack",
|
|
22
|
+
"api_gateway": {
|
|
23
|
+
"name": "geek-cafe-prod-api",
|
|
24
|
+
"api_type": "REST",
|
|
25
|
+
"stage_name": "prod",
|
|
26
|
+
"ssm": {
|
|
27
|
+
"enabled": true,
|
|
28
|
+
"auto_export": true,
|
|
29
|
+
"workload": "geek-cafe",
|
|
30
|
+
"environment": "prod",
|
|
31
|
+
"imports": {
|
|
32
|
+
"workload": "geek-cafe",
|
|
33
|
+
"environment": "prod",
|
|
34
|
+
"user_pool_arn": "auto" // ✅ ADD THIS - imports from Cognito stack
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"cognito_authorizer": {
|
|
38
|
+
"authorizer_name": "geek-cafe-cognito-authorizer"
|
|
39
|
+
},
|
|
40
|
+
"routes": [...]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This assumes your Cognito stack is configured to export:
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"name": "geek-cafe-prod-cognito",
|
|
49
|
+
"module": "cognito_stack",
|
|
50
|
+
"ssm": {
|
|
51
|
+
"enabled": true,
|
|
52
|
+
"auto_export": true, // ✅ Must be enabled
|
|
53
|
+
"workload": "geek-cafe",
|
|
54
|
+
"environment": "prod"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Option 2: Use Explicit SSM Path
|
|
60
|
+
|
|
61
|
+
If auto-discovery doesn't work, find the exact SSM parameter:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Find the parameter
|
|
65
|
+
aws ssm get-parameters-by-path --path "/geek-cafe/prod/cognito" --recursive
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then use the explicit path:
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"api_gateway": {
|
|
72
|
+
"ssm": {
|
|
73
|
+
"imports": {
|
|
74
|
+
"user_pool_arn": "/geek-cafe/prod/cognito/user-pool/user-pool-arn"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Option 3: Direct ARN (Quick Temporary Fix)
|
|
82
|
+
|
|
83
|
+
If you just need to deploy NOW and fix properly later:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"api_gateway": {
|
|
88
|
+
"cognito_authorizer": {
|
|
89
|
+
"authorizer_name": "geek-cafe-authorizer",
|
|
90
|
+
"user_pool_arn": "arn:aws:cognito-idp:us-east-1:ACCOUNT_ID:userpool/us-east-1_XXXXX"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Get the ARN from AWS Console → Cognito → User Pools → geek-cafe-prod → ARN
|
|
97
|
+
|
|
98
|
+
## Deployment Order
|
|
99
|
+
|
|
100
|
+
With the new pattern, deploy in this order:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 1. Deploy Cognito (if separate stack)
|
|
104
|
+
cdk deploy geek-cafe-prod-cognito
|
|
105
|
+
|
|
106
|
+
# 2. Deploy Lambdas
|
|
107
|
+
cdk deploy geek-cafe-prod-lambdas
|
|
108
|
+
|
|
109
|
+
# 3. Deploy API Gateway (imports from both above)
|
|
110
|
+
cdk deploy geek-cafe-prod-api-gateway
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Or set up a pipeline with stages:
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"pipeline": {
|
|
117
|
+
"stages": [
|
|
118
|
+
{"name": "infrastructure", "stacks": ["cognito-stack"]},
|
|
119
|
+
{"name": "lambdas", "stacks": ["lambda-stack"]},
|
|
120
|
+
{"name": "api-gateway", "stacks": ["api-gateway-stack"]}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Verify SSM Parameters Exist
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Check what Cognito exported
|
|
130
|
+
aws ssm get-parameter --name "/geek-cafe/prod/cognito/user-pool/user-pool-arn"
|
|
131
|
+
|
|
132
|
+
# Check what Lambda exported
|
|
133
|
+
aws ssm get-parameters-by-path --path "/geek-cafe/prod/lambda" --recursive
|
|
134
|
+
|
|
135
|
+
# Check what API Gateway exported
|
|
136
|
+
aws ssm get-parameters-by-path --path "/geek-cafe/prod/api-gateway" --recursive
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Complete Example Config
|
|
140
|
+
|
|
141
|
+
**cognito-stack.json:**
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"name": "geek-cafe-prod-cognito",
|
|
145
|
+
"module": "cognito_stack",
|
|
146
|
+
"ssm": {
|
|
147
|
+
"enabled": true,
|
|
148
|
+
"auto_export": true,
|
|
149
|
+
"workload": "geek-cafe",
|
|
150
|
+
"environment": "prod"
|
|
151
|
+
},
|
|
152
|
+
"cognito": {
|
|
153
|
+
"user_pool_name": "geek-cafe-prod",
|
|
154
|
+
"exists": false
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**lambda-stack.json:**
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"name": "geek-cafe-prod-lambdas",
|
|
163
|
+
"module": "lambda_stack",
|
|
164
|
+
"ssm": {
|
|
165
|
+
"enabled": true,
|
|
166
|
+
"workload": "geek-cafe",
|
|
167
|
+
"environment": "prod"
|
|
168
|
+
},
|
|
169
|
+
"resources": [
|
|
170
|
+
{
|
|
171
|
+
"name": "geek-cafe-prod-get-cafes",
|
|
172
|
+
"src": "./src/handlers/cafes",
|
|
173
|
+
"handler": "get_cafes.lambda_handler"
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**api-gateway-stack.json:**
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"name": "geek-cafe-prod-api-gateway",
|
|
183
|
+
"module": "api_gateway_stack",
|
|
184
|
+
"api_gateway": {
|
|
185
|
+
"name": "geek-cafe-prod-api",
|
|
186
|
+
"api_type": "REST",
|
|
187
|
+
"stage_name": "prod",
|
|
188
|
+
"ssm": {
|
|
189
|
+
"enabled": true,
|
|
190
|
+
"auto_export": true,
|
|
191
|
+
"workload": "geek-cafe",
|
|
192
|
+
"environment": "prod",
|
|
193
|
+
"imports": {
|
|
194
|
+
"workload": "geek-cafe",
|
|
195
|
+
"environment": "prod",
|
|
196
|
+
"user_pool_arn": "auto" // ✅ This is the key fix
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"cognito_authorizer": {
|
|
200
|
+
"authorizer_name": "geek-cafe-cognito-authorizer"
|
|
201
|
+
},
|
|
202
|
+
"routes": [
|
|
203
|
+
{
|
|
204
|
+
"path": "/cafes",
|
|
205
|
+
"method": "GET",
|
|
206
|
+
"lambda_name": "geek-cafe-prod-get-cafes",
|
|
207
|
+
"authorization_type": "COGNITO_USER_POOLS"
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Summary of Changes
|
|
215
|
+
|
|
216
|
+
| Old Pattern (Combined) | New Pattern (Separated) |
|
|
217
|
+
|------------------------|-------------------------|
|
|
218
|
+
| `COGNITO_USER_POOL_ID` env var | SSM import with `user_pool_arn: "auto"` |
|
|
219
|
+
| Single stack with Lambda + API | Three stacks: Cognito → Lambda → API Gateway |
|
|
220
|
+
| Environment vars in CI/CD | Config-driven SSM parameters |
|
|
221
|
+
| `"exports": {"enabled": true}` ❌ | `"auto_export": true` ✅ |
|
|
222
|
+
|
|
223
|
+
## If Still Having Issues
|
|
224
|
+
|
|
225
|
+
1. **Check CDK Factory version:**
|
|
226
|
+
```bash
|
|
227
|
+
pip show cdk-factory
|
|
228
|
+
# Should be v0.8.0 or higher
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
2. **Enable debug logging:**
|
|
232
|
+
```bash
|
|
233
|
+
export LOG_LEVEL=DEBUG
|
|
234
|
+
cdk deploy
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
3. **Verify workload/environment match** in all three stacks
|
|
238
|
+
|
|
239
|
+
4. **Check SSM permissions** in your deployment role
|
|
240
|
+
|
|
241
|
+
5. **Use explicit path** as fallback if auto-discovery fails
|
|
@@ -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,81 @@
|
|
|
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
|
+
"auto_export": true,
|
|
13
|
+
"workload": "{{WORKLOAD_NAME}}",
|
|
14
|
+
"environment": "{{ENVIRONMENT}}",
|
|
15
|
+
"imports": {
|
|
16
|
+
"workload": "{{WORKLOAD_NAME}}",
|
|
17
|
+
"environment": "{{ENVIRONMENT}}"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"deploy_options": {
|
|
21
|
+
"data_trace_enabled": false,
|
|
22
|
+
"metrics_enabled": true,
|
|
23
|
+
"tracing_enabled": true,
|
|
24
|
+
"throttling_rate_limit": 1000,
|
|
25
|
+
"throttling_burst_limit": 2000
|
|
26
|
+
},
|
|
27
|
+
"cognito_authorizer": {
|
|
28
|
+
"enabled": false,
|
|
29
|
+
"user_pool_arn": "{{COGNITO_USER_POOL_ARN}}"
|
|
30
|
+
},
|
|
31
|
+
"routes": [
|
|
32
|
+
{
|
|
33
|
+
"path": "/health",
|
|
34
|
+
"method": "GET",
|
|
35
|
+
"lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-health-check",
|
|
36
|
+
"authorization_type": "NONE",
|
|
37
|
+
"allow_public_override": true,
|
|
38
|
+
"cors": {
|
|
39
|
+
"origins": ["*"],
|
|
40
|
+
"methods": ["GET", "OPTIONS"],
|
|
41
|
+
"headers": ["Content-Type", "Authorization"]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "/users",
|
|
46
|
+
"method": "GET",
|
|
47
|
+
"lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-user-api",
|
|
48
|
+
"authorization_type": "NONE",
|
|
49
|
+
"allow_public_override": true,
|
|
50
|
+
"cors": {
|
|
51
|
+
"origins": ["*"],
|
|
52
|
+
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
53
|
+
"headers": ["Content-Type", "Authorization"]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "/users",
|
|
58
|
+
"method": "POST",
|
|
59
|
+
"lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-user-api",
|
|
60
|
+
"authorization_type": "NONE",
|
|
61
|
+
"allow_public_override": true,
|
|
62
|
+
"cors": {
|
|
63
|
+
"origins": ["*"],
|
|
64
|
+
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
65
|
+
"headers": ["Content-Type", "Authorization"]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"path": "/admin/stats",
|
|
70
|
+
"method": "GET",
|
|
71
|
+
"lambda_name": "{{WORKLOAD_NAME}}-{{ENVIRONMENT}}-admin-api",
|
|
72
|
+
"authorization_type": "COGNITO",
|
|
73
|
+
"cors": {
|
|
74
|
+
"origins": ["https://admin.example.com"],
|
|
75
|
+
"methods": ["GET", "OPTIONS"],
|
|
76
|
+
"headers": ["Content-Type", "Authorization"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|