DEV Community

Cover image for CDK for Terraform - Setup & Configure
Arindam Mitra
Arindam Mitra

Posted on

CDK for Terraform - Setup & Configure

Greetings my fellow Technology Advocates and Specialists.

This is Chapter #2 of my Terraform CDK (Cloud Development Kit) Series.

In this Session, I will demonstrate How to Setup and Configure Terraform CDK (Cloud Development Kit) to define Infrastructure.

I had the Privilege to talk on this topic in ONE Azure Communities:-

NAME OF THE AZURE COMMUNITY TYPE OF SPEAKER SESSION
Global Azure - 2024 Virtual
EVENT ANNOUNCEMENTS:-
Image description
CODE REPOSITORY:-



POINTS TO NOTE:-
1. Cloud Provider is Microsoft Azure.
1. Language used here is TYPESCRIPT.
2. Browse to each folder under "03-Code-Source" (for example - Resource-Group) and look for "main.ts" for the TypeScript Code.
PRE-REQUISITES:-
1. Install Terraform.
1
If Required, Upgrade Terraform Version with Chocolatey Package Manager.
2
2. Install Node and Yarn
3
3. Install CDKTF
4
Verify CDKTF Installation
5
6
LOCAL DIRECTORY STRUCTURE FOR CODE:-
7
INITIALIZE CDK FOR TERRAFORM LOCALLY:-
8
9
FILES AND FOLDERS CREATED AFTER CDK FOR TERRAFORM IS INITIALIZED:-
10
OUTPUT OF CDKTF SYNTH:-
All-Issue-Resolved-CDKTF-SYNTH
OUTPUT OF CDKTF DEPLOY:-
CDKTF-Deploy
OUTPUT FROM AZURE PORTAL:-
Image description
BELOW FOLLOWS ALL THE TROUBLESHOOTING STEPS:-
ERROR #1:-
Err-1
RESOLUTION:-
The Correct Command is - cdktf init --template=typescript --local
ERROR #2:-
Err-2
RESOLUTION:-
In the Sytem from where you are executing terraform CDK commands, browse to "C:\Program Files\nodejs"
Edit the below files, mentioned in the screenshot as per the link - https://stackoverflow.com/questions/72401421/message-npm-warn-config-global-global-local-are-deprecated-use-loc
image
ERROR #3:-
Err-3
RESOLUTION:-
Follow the Resolution provided in the link - https://flaviocopes.com/typescript-disable-declared-never-read/
tsconfig-json
ERROR #4:-
Err-4
RESOLUTION:-
Close Parenthesis was missing in the code snippet.
ERROR #5:-
Err-5
RESOLUTION:-
Below Code block was missing.
new AzurermProvider(this, "AzureRm", {
      features: {},
    });
Enter fullscreen mode Exit fullscreen mode
ERROR #6:-
Err-cdktf-deploy-1
RESOLUTION:-
The Refresh token has expired due to inactivity. We need to execute "az login" command.
az-login

Hope You Enjoyed the Session!!!

Stay Safe | Keep Learning | Spread Knowledge

Top comments (0)