This is a collection of reusable constructs and patterns for CDK setups, for use within Liflig.
We do not expect others to depend on this, and as such will not be following semantic versioning strictly. There will be breaking changes across both minor and patch releases, as we will be coordinating changes internally.
CDK has some major issues for 3rd party library authors which are not yet resolved. Some relevant information:
Lint code
npm run lint
Run tests and update snapshots
npm run snapshots
npm run test -- -u
Investigate any changes before committing.
Assemble artifact, which emits a tarball
npm pack
Install the library in an application from a tarball
npm install /path/to/liflig-cdk/liflig-cdk-0.0.0-development.tgz
Navigate to the project where you want to test the changes
cd /path/to/other/project
Install the library in an application from a Git branch
npm install github:capralifecycle/liflig-cdk#remove-del-and-glob-packages
Note: npm link cannot be used, since it will lead to multiple
declarations of the same classes from CDK, breaking the instanceof
operator.
When updating lambda function runtimes or handler code, we sometimes need to verify that the lambda runs correctly aside from being syntactically correct, such as ensuring imports in handler code are valid for the specified runtime, that required environment variables exist, and so on.
Some specific approaches to validating specific lambda functions in this project:
src/alarms/slack-alarm.ts:slackLambda
aws cloudwatch set-alarm-state --state-value "ALARM" ...), which posts to the SNS topic and triggers the function. We can then verify that the function executes correctly by checking the Slack channel for the alarm notification, as well as the function logs in CloudWatch.src/cdk-pipelines/liflig-cdk-pipeline.ts:prepareCdkSourceFn
PrepareCdkSource step.src/cdk-pipelines/slack-notification.ts:reportFunction
This project accepts contributions. To get started, see the Contributing Guidelines.