CDK for Terraform

learn cdktf. based on Build AWS Infrastructure with TypeScript


  • cdktf generates tf hcl json
  • cdktf synth creates cdktf.out
  • can use tf apply within a cdktf.out/stacks/* directory to deploy
  • or let cdktf do both the synth and tf deploy


cdktf init --template=typescript --local

# add aws provider to `cdktf.json` // "hashicorp/aws@~> 3.42"

# creates `.gen` folder which is codegend .ts
cdktf get

# edit `main.ts`

# deploy
cdktf deploy

# clean up
cdktf destroy

Directory Structure

Deploy Output

Destroy Output