Borislav Hadzhiev
Thu Apr 14 2022·2 min read
Photo by Sharon Rørvik
Updated - Thu Apr 14 2022
In order to create a new CDK App we have to use the cdk init
command. For
example:
mkdir cdk-app cd cdk-app npx aws-cdk init app --language=typescript
We can write our CDK code in many programming languages and init our CDK app
from multiple starter templates, to list the available options we can append the
--list
flag to the command:
npx aws-cdk init --list
The output shows all the available programming languages we can use in our CDK app and all of the available starter templates:
There are 3 templates we can start from:
app
- a basic starter templatelib
- a template for writing a CDK construct librarysample-app
- a starter with some constructs includedNote that cdk init cannot be run in a non-empty directory, so we first have to create one:
mkdir cdk-app cd cdk-app npx aws-cdk init app --language=typescript
The output from the command looks like:
At this point we have successfully initialized an empty CDK project.
If you want to specify an AWS CLI profile, other than your default one to be
used as the default environment for your CDK App, you can pass the --profile
flag, i.e.:
mkdir cdk-app cd cdk-app npx aws-cdk init app \ --language=typescript \ --profile=my-profile