DEV Community

Cover image for Tips and Tricks for Developing CDK Construct using Projen
Marko - ServerlessLife.com
Marko - ServerlessLife.com

Posted on • Originally published at serverlesslife.com

Tips and Tricks for Developing CDK Construct using Projen

Projen is an essential tool for creating CDK constructs. But it is opinionated. We will look into tips and tricks on how to overcome its constraints.

Projen is a multipurpose project generator. Among other things, it can be used for building a CDK construct.

Why would you need a special tool like Projen for creating a CDK construct? 

Creating a CDK construct is as easy as extending a Construct class:

export class LambdaErrorSnsSender extends Construct {
  constructor(scope: Construct, id: string, props: LambdaErrorSnsSenderProps) {
    super(scope, id);
    
  }
}
Enter fullscreen mode Exit fullscreen mode

If you are building a CDK construct that you intend to use in the same solution, you do not need anything else. But if you want to ship the construct to open source repos: Npm, Maven, Pypi, Nuget, or Go, you must transpile your code construct from TypeScript to other languages, package them, and deploy them to the desired repo. And you would need to do that in CI/CD. This is where Projen comes in. It sets up the whole environment with all the features and bells and whistles that you may need. 

The Projen provides the following features when building a CDK construct:

  1. Compile, lint, and test the code.
  2. Use JSII to produce library artifacts for all target languages.
  3. Determine the next minor/patch version based on conventional commits
  4. A changelog entry is generated based on the commit history.
  5. Packages are published to all target package managers.

Continue reading on www.serverlesslife.com...

Top comments (0)