-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/cdk migration #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/cdk migration #1102
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
91fd3a4
Increment root package version, move to node 22
tvhees c4cadcf
Add root CDK application and test-cdk-service
tvhees 654f2c5
Rename cdk folder to application
tvhees b3f62c9
Add CDK migration notes, version and alias resources, lambda defaults…
tvhees 19a2004
Reduce output from step function tasks with Jsonata
tvhees 2d0955b
small refactor of lambdas and step function
tvhees 8db7ebd
Added an example using JSONata and non-lambda resources in step funct…
tvhees 88e5094
Avoid linting CDK output folder
tvhees 02cc563
Extract constructs to cdk-utils, provide injector for name overrides,…
tvhees eb52cee
Minor fixes
tvhees 9a96131
Rework vite/eslint config to mjs format and document lib requirements…
tvhees 27e3594
Update CDK utils lib to match new lib standards
tvhees ead5b3b
Fix issues with nx g remove stumbling on eslint.config.js
tvhees 0798ec7
Move vitest workspace to mjs
tvhees 3fc6db3
Keep vitest.workspace.ts with a comment
tvhees 245ca3d
Add tests and docs to cdk service example
tvhees 84a1b86
Rework context, create custom cdk-nag ruleset, use it to test service…
tvhees 8bf682a
Add typechecks, tests for cdk-utils, and drop coverage requirement fo…
tvhees 1e532e3
Added generator for cdk services
tvhees 5d24e9b
Clean up generators. move all context to application-context, add pla…
tvhees fb085f9
Update readmes
tvhees f7edf10
Remove legacy service example
tvhees f1016d9
Namespace cd-utils and add better readme instructions
tvhees c61d766
Generator produces a better stack test file
tvhees e12081e
Further test improvements for generated services
tvhees 02a2464
Guard against Stack or Service in new service names
tvhees 9598585
Minor addition to migration notes
tvhees 0a19ce2
Clean up example cdk service
tvhees 34d4c5d
Don't recommend immutable install, iit fails due to package name change
tvhees 42b3459
Add note about confirming change deployment
tvhees beae0fb
Change dev deploy command syntax and add destroy command
tvhees f422aa0
Improve readme docs for initial app management
tvhees e138e95
Total overhaul adding the latest state of the cdk template
tvhees c69c948
Fix cdk-service generator issue
tvhees 1be23dc
Add owner tag to the whole application
tvhees 3868fca
Refactor log group properties into a separate file and enhance loggin…
tvhees d4defe4
Migrate to Nx 2.3.11, update other deps
tvhees 7ad959a
Streamline cdk-service generator template, remove unnecessary extension
tvhees 9fbfb80
Add esm support banner to lambda bundling
tvhees 5c3b575
Clean up nvm use in pre-commit hook, disable Nx terminal ui
tvhees 53ab90b
Migrate to new application structure
tvhees 16eaf66
Add defaults for pg task
tvhees dea15eb
Gitignore .env.json file
tvhees 35f4786
Add required configuration for pg:parameters in core application
tvhees 3d5f030
Update core application reference for @nx/js/typescript plugin
tvhees fb99abb
Update generator and add readme notes around adding/removing services
tvhees 7a30317
Add updated bitbucket pipelines config
tvhees cef0716
Update playground: to pg: in docs
tvhees a0c56cc
Make `origin/main` the default comparison branch and add a note about…
tvhees 53d35b9
Clean up gitignore, commit CLAUDE.md
tvhees 204a68a
Remove default AWS account/region config from application
tvhees 0b57fc2
Fix missing import of Stage in generator index.ts
tvhees 8e2b492
Chore: Developer QOL adjustments for commit and pg deploys
tvhees 8be2c2e
Test Nx Package should use node 22 and cdk-service
tvhees f652e7c
Fix CLI argument handling of cdk-service-plugin generator, rename gen…
tvhees 58dc962
Avoid yarn lock error when generating test library
tvhees 1c40ef3
Turn off immutable installs just for package build test
tvhees 43cee54
Use yarn for all package build commands, don't run test task in packa…
tvhees 3cd4033
Overhaul stage setup and cdk-utils to use property injectors and aspe…
tvhees 4c3825e
Update documentation and CLAUDE.md
tvhees ee8c440
Improve types and documentation for SSM Parameter Group
tvhees 54b644d
Make injector withProps method return a new instance, improve JSDocs
tvhees 8693cf7
Consilidate bucket constructs, rework injectors to use configuration …
tvhees 2a05e44
Update cdk-utils readme and CLAUDE files
tvhees ff9b8bb
Move to using store-parameters package over a custom script for SSM p…
tvhees 33b4665
Code review changes
tvhees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20.18 | ||
v22.14.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# CLAUDE.md | ||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
||
## Essential Commands | ||
|
||
### Testing | ||
|
||
- **Run tests for affected projects**: `yarn test` | ||
- **Run tests for all projects**: `yarn test:all` | ||
- **Run a single test file**: `npx vitest run path/to/test.spec.ts` | ||
- **Run tests in watch mode**: `npx vitest watch` | ||
- **Run tests for specific project**: `npx nx test @libs/cdk-utils` | ||
- **Run specific test file with Nx**: `npx nx test @libs/cdk-utils -- path/to/test.spec.ts` | ||
|
||
### Code Quality | ||
|
||
- **Lint affected projects**: `yarn lint` | ||
- **Lint all projects**: `yarn lint:all` | ||
- **Type check affected projects**: `yarn typecheck` | ||
- **Type check all projects**: `yarn typecheck:all` | ||
|
||
### Service Management | ||
|
||
- **Generate new service**: `npx nx g service <service-name>` | ||
- **Generate notification service**: `npx nx g service <service-name> notification` | ||
- **Deploy service to AWS**: `npx nx deploy <service-name> -- -s <stage> --aws-profile <profile>` | ||
- **Remove service from AWS**: `npx nx run <service-name>:remove -- -s <stage> --aws-profile <profile>` | ||
|
||
### CDK Deployment | ||
|
||
- **Deploy all stacks**: `cd applications/core && cdk deploy` | ||
- **Deploy staging stacks**: `cd applications/core && cdk deploy stg/**` | ||
- **Deploy production stacks**: `cd applications/core && cdk deploy prd/**` | ||
- **View CDK diff**: `cd applications/core && cdk diff` | ||
|
||
### API Client Generation | ||
|
||
- **Generate typed API client**: `npx nx g client <client-name>` | ||
|
||
## Architecture Overview | ||
|
||
This is an AWS microservices template using: | ||
|
||
- **Nx monorepo** structure with services in `services/` and libraries in `libs/` | ||
- **AWS CDK v2** for infrastructure as code (recently migrated from Serverless Framework) | ||
- **TypeScript** with strict type checking extending @aligent/ts-code-standards | ||
- **Node.js 22.14.0** runtime | ||
|
||
### Key Architecture Patterns | ||
|
||
1. **Service-Based Architecture** | ||
|
||
- Each service is a separate CDK Stack defined in `services/<service-name>/src/index.ts` | ||
- Services export a Stack class that extends `aws-cdk-lib.Stack` | ||
- Services are imported and instantiated in `ApplicationStage` inside `applications/core/bin/main.ts` | ||
|
||
2. **CDK Application Structure** | ||
|
||
- Entry point: `applications/core/bin/main.ts` creates CDK App and stages | ||
- Stages (dev/stg/prd) are created as ApplicationStage instances directly in `main.ts` | ||
- Stage-specific configuration is applied via property injectors and aspects | ||
- Each stage automatically configures resources based on deployment environment | ||
|
||
3. **Lambda and Step Functions** | ||
|
||
- Lambda functions are in `services/<service>/src/lambda/` | ||
- Step Functions use YAML definitions in `services/<service>/src/step-functions/` | ||
- Shared constructs in `services/<service>/src/lib/constructs/` | ||
- Step Functions use JSONata for output transformations | ||
- Automatic versioning and aliasing applied via VersionFunctionsAspect | ||
- Stage-specific configuration applied via property injectors | ||
|
||
4. **Property Injection Architecture** | ||
|
||
- Configuration-based defaults applied via property injectors: | ||
- **NodeJsFunctionDefaultsInjector**: Bundling configuration (sourceMap, esm, minify) | ||
- **LogGroupDefaultsInjector**: Duration-based retention (SHORT/MEDIUM/LONG) | ||
- **StepFunctionDefaultsInjector**: Automatic logging for EXPRESS workflows | ||
- **BucketDefaultsInjector**: Auto-cleanup policies for S3 buckets | ||
- Cross-cutting concerns handled by aspects (VersionFunctionsAspect for automatic versioning) | ||
- Configuration can be customized per stage or globally | ||
- Uses CDK's built-in property injection system - no custom constructs needed | ||
|
||
5. **CDK Constructs and Utilities** | ||
|
||
- **S3Bucket**: Lifecycle management with duration-based rules (SHORT/MEDIUM/LONG/PERMANENT) | ||
- **SsmParameterGroup**: Abstract class for grouping and managing SSM parameters | ||
- **StepFunctionFromFile**: Load Step Function definitions from YAML/JSON files | ||
|
||
6. **Testing Strategy** | ||
- Vitest for unit testing with coverage reports | ||
- Test files colocated with source files as `*.spec.ts` or `*.test.ts` | ||
- Workspace-level Vitest configuration in `vitest.workspace.ts` | ||
|
||
## Important Context | ||
|
||
### CDK Migration Notes | ||
|
||
- Project migrated from Serverless Framework to CDK using property injection pattern | ||
- CDK construct IDs are critical - changing them will replace resources | ||
- Lambda versions and aliases are automatically created via VersionFunctionsAspect | ||
- Step Functions use `LambdaInvoke` resource with automatic retry blocks | ||
- Task outputs are nested in `Payload` property - use JSONata to transform | ||
- Stage-specific resource configuration handled by property injectors | ||
|
||
### Configuration | ||
|
||
- Update brand name in `nx.json` generators section before first use | ||
- Package name in `package.json` should follow `@<brand>-int/integrations` format | ||
- Services are tagged with STAGE and SERVICE tags automatically | ||
|
||
### Development Workflow | ||
|
||
1. Always run lint and type checks before committing | ||
2. Use Nx affected commands to optimize CI/CD performance | ||
3. Follow existing code patterns and conventions in the codebase | ||
4. Check `CDK-MIGRATION-NOTES.md` for CDK-specific guidance | ||
|
||
## AI Helpers | ||
|
||
The `docs/ai-helpers/` folder contains documentation templates to assist AI code assistants in creating consistent and comprehensive documentation: | ||
|
||
### Recommended MCP Servers | ||
|
||
When using Claude Code or other MCP-compatible tools, the following MCP servers are recommended for this repository: | ||
|
||
- **context7**: Provides up-to-date documentation for libraries and frameworks | ||
- **eslint**: Enables linting capabilities for code quality checks | ||
- **nx**: Offers Nx-specific commands and workspace insights | ||
|
||
These servers should be used when available to enhance development capabilities. | ||
|
||
### Available Templates | ||
|
||
- **`APPLICATION_ARCHITECTURE_FORMAT.md`**: Template for creating comprehensive architecture diagrams for AWS CDK services | ||
- Provides guidelines for analyzing CDK application structure | ||
- Includes Mermaid diagram formats with consistent color palettes | ||
- Shows how to map Step Function workflows and Lambda functions | ||
- Contains common architectural patterns and best practices | ||
|
||
- **`SERVICE_README_FORMAT.md`**: Template for creating service-specific README documentation | ||
- Standardized format for service documentation | ||
- Context diagram template showing external system interactions | ||
- Sections for workflows, critical information, and operational details | ||
- Consistent color palette for system visualization | ||
|
||
### When to Use | ||
|
||
Reference these templates when: | ||
- Creating new architecture documentation (`ARCHITECTURE.md`) | ||
- Documenting a new service with a README | ||
- Updating existing service documentation | ||
- Generating visual representations of service interactions | ||
- Ensuring consistency across all service documentation |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.