Projen is a tool designed to simplify the process of managing and maintaining AWS Cloud Development Kit (CDK) projects. It helps automate the creation, configuration, and maintenance of CDK applications by generating and managing project files, dependencies, and build tools. Projen is particularly useful for developers who want to focus on writing the infrastructure code rather than worrying about project setup, versioning, or boilerplate configurations.
Add Projen to an empty project
yarn add projen
Create default projen project with the template type awscdk-construct
npx projen new awscdk-construct
This will create a lot of files but they are all driven from the .projenrc.js file, with Projen you do not need to modify the other files like package.json
NPM does not like packages with capitals in them so we will add to the Projen rc file
packageName: 'cdk-custom-domain-lib',
This will set the name in package.json and will be used in the npm libs. Run Projen to see updates.
npx projen
Next login to npm or create an account if you don’t have one. https://www.npmjs.com/ Once logged in navigate to Access Tokens and click generate new token. The token will be an automation token.
Goto the GitHub repository (you may need to push one) and select settings. In settings navigate to secrets and variables. Under actions you are going to create a new repository secret called NPM_TOKEN, paste the token created on npm as the value.
Next navigate to Fine-grained personal access tokens, this can be found in developer setting in your GitHub settings page.
Create a new PAT and set the following permissions to read write for the created repository:
- Actions
- Contents
- Pull requests
- Workflows
The token generated will be added as a new repository secret called PROJEN_GITHUB_TOKEN
Now you can publish the changes to GitHub. Clicking on Actions you should see the first release action running.
On completion you should then see an npm package added to your account


Now you can add this new package to your other projects and test the built in code.

Categories: AWS
Leave a comment