In this part you are going to create a new CDK application.
STEP 1 Create a new directory for the application.
mkdir myapp && cd myapp
STEP 2 initiate a new CDK application by executing command below.
cdk init app --language typescript
You will notice new files and directory in the myapp
directory.
STEP 3 Create a new terminal by clicking on the green cross, and click New Terminal.
STEP 4 In the new terminal, go to our app by executing this command.
cd myapp
STEP 5 You need to compile your Typescript code to Javascript everytime you create or update a Typescript file. To do that execute the code below.
npm run watch
If you by any chance close this terminal, you need to redo the step in new terminal.
STEP 6 Go back to our previous terminal.
STEP 7 Now you may want to see the CloudFormation template that will be generated by the CDK code. Execute the command below.
cdk synth
The command will output YAML text that contains CloudFormation template.
STEP 8 Before you deploy the CDK code to our AWS account, you need to provision CDK resources that is required by CDK to store assets. This can charge small cost to your AWS account, you are going to delete the resources in the last part of the workshop.
Execute command below to bootstrap.
cdk bootstrap
It will output something a bit similar to text below.
⏳ Bootstrapping environment aws://1234567890/us-east-1...
✅ Environment aws://1234567890/us-east-1 bootstrapped (no changes).
STEP 9 To deploy the CDK application, execute command below.
cdk deploy
This will output text a bit similar to text below.
Stack ARN:
arn:aws:cloudformation:us-east-1:1234567890:stack/MyappStack/aaaaaaaa-bbbb-cccc-dddd-ffffffffffff
To check whether the stack is deployed, open CloudFormation console and see if a new stack MyappStack is deployed.
NOTE
If in the next cdk deploy
, your IDE shows insufficient space, try deleting the content of the cdk.out
directory by executing the following command in the project root directory.
rm -rf cdk.out/*
Click the orange arrow on the right hand side to continue to next step.