CDK for Terraform - Setup & Configure

arindam0310018

Arindam Mitra

Posted on April 17, 2024

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:-

Terraform CDK Series with Azure:-

Greetings to my fellow Technology Advocates and Specialists.

In this Session, I talk and run Demo on TERRAFORM CDK SERIES in below TECH COMMUNITIES:-

NAME OF THE TECH COMMUNITIES:-
Global Azure - 2024
DATE TOPICS CONTENT
17.04.2024 CDK for Terraform - Quickstart https://dev.to/arindam0310018/cdk-for-terraform-quickstart-1h3e
17.04.2024 CDK for Terraform - Setup & Configure https://dev.to/arindam0310018/cdk-for-terraform-setup-configure-f42
05.05.2024 CDK For Terraform: MS Hosted Windows Build Agent https://dev.to/arindam0310018/cdk-for-terraform-ms-hosted-windows-build-agent-3mon
05.05.2024 CDK For Terraform: MS Hosted Linux Build Agent https://dev.to/arindam0310018/cdk-for-terraform-ms-hosted-linux-build-agent-1egi



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

💖 💪 🙅 🚩
arindam0310018
Arindam Mitra

Posted on April 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related