DEV Community

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

Posted on • Edited on

1

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 TWO Azure Communities:-

NAME OF THE AZURE COMMUNITY TYPE OF SPEAKER SESSION
Microsoft Azure Zurich User Group (Global Azure - 2024) Virtual
.NET Zurich User Group In-Person
EVENT ANNOUNCEMENTS:-
Image description
VIRTUAL SESSION:-
LIVE DEMO was Recorded as part of my Presentation in Microsoft Azure Zurich User Group (Global Azure - 2024) Forum/Platform
Duration of My Demo = 32 Mins 55 Secs
EVENT ANNOUNCEMENTS:-
Image description
IN-PERSON SESSION:-
LIVE DEMO was Recorded as part of my Presentation in .NET Zurich User Group Forum/Platform
Start Time of My Demo = 01 Hour 08 Mins 03 Secs
Duration of My Demo = 47 Mins 51 Secs
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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay