Projen
I saw projen a few months back but it wasn’t until @emeshbi’s presentation on CDK Day 2020 that I realized I needed this in my life. The AWS CDK is amazing and I’ve been using it for a little over a year now. Unfortunately there are a few things missing from a basic cdk init
that projen really helps with such as cdk version management, dependencies, jsii, and the list goes on…
External Projects
To quote projen: “projen takes a “batteries included” approach and aims to offer dozens of different project types out of the box”. projen is flexible and extensible, however, previously it did not support external projects (see RFC 193). This meant that either ANY project type you wanted for your internal organization would have to be added to projen itself or use some other method of bundling and dependency managedment, which I tried. As of today external project support is available and it’s simple to add your own projects and use them with projen!
npx projen new --from my-npm-module --description "Check me out!"
AppSync Project
Back in April I wrote a blog post on using AppSync with the CDK. Since then I’ve released a cdk construct that “emulates AWS Amplify’s method of using GraphQL directives in order to template a lot of the Schema Definition Language”. This makes it easy to spin up an AppSync API connected to Cognito, DynamoDB and Lambda.
To make this even easier I have released an external projen compatible project, cdk-appsync-project, to simplify adding the transformer and generating a templated AWS AppSync API with Cognito and an example schema. All you have to do is:
npx projen new --from cdk-appsync-project --cdk-version-pinning true --cdk-version "1.63.0"
And that’s it! You now have a stubbed out AWS AppSync API with cognito and a sample schema.graphql
. It isn’t quite as powerful as the AWS Amplify CLI but if you want to quickly spin up a serverless graphql api and use the cdk this is about as quick as it gets!
All you have to deploy is configure the schema as desired and run:
yarn deploy
Go Try It Yourself!
Now that projen supports external projects you can build almost anything you need: internally or externally. It’s now simple to build and manage by specifying opinionated, versioned project types.