Skip to main content
This page contains links to tutorials, example projects in every supported language, explanatory videos, and other resources to help you learn to create and manage CDK Terrain (CDKTN) applications.

Tutorials

Follow these hands-on tutorials:
TutorialDescription
Install CDKTN and Run a Quick Start DemoWrite TypeScript code that will provision an NGINX server using Docker on Mac, Windows, or Linux.
Build AWS Infrastructure with TypeScript, Python, Java, C#, or GoProvision an EC2 instance on AWS using TypeScript.
Deploy Multiple Lambda Functions with TypeScriptDeploy a CDKTN application made up of two stacks, each containing a simple AWS Lambda function written in TypeScript.
Deploy Applications with CDK TerrainUse CDKTN to deploy an application on Kubernetes.

Example Projects

The Terraform Registry and OpenTofu Registry have more information about all of the providers in the following examples.

Typescript

ExampleDescriptionComplexity
aws-ecs-docker-and-static-frontendUses a backend service in a Docker container with a static frontend running in Amazon Web Services (AWS). Walk through AWS setup and configuring the backend to run against a Postgres Database.High
aws-lambda-end-to-endAn end-to-end example for a serverless web application hosted on AWS.High
aws-prebuiltProvisions a DynamoDB table on the prebuilt AWS provider.Low
aws-multiple-stacksUses Stacks to pass different settings into the development, staging, and production environments.Low
aws-cloudfront-proxyUses AWS Cloudfront as a SSL proxy server for any existing domain.Low
azureProvisions a Virtual Network on Microsoft Azure.Low
azure-app-serviceUses the Azure App Service to deploy a Docker image.Low
dockerStarts a Docker container with an NGINX server.Low
ecs-microservices-cdktnCreates a microservice architecture on AWS ECS Fargate with Datadog monitoring using the CDK TerrainHigh
googleCreates a simple Compute Instance with the Google Cloud Platform Provider.Low
google-cloudrunDefines a Google Cloud Run service with a hello world container.Low
kubernetesSets up a Kubernetes Deployment with a NGINX container.Low
ucloudProvisions a Linux base image on UCloud.Low
vaultCreates a Mount in Vault.Low

Backends

Each CDK Terrain project can specify a backend that defines where and how Terraform operations are performed, where Terraform state snapshots are stored, etc.
ExampleDescriptionComplexity
azurermSpecifies Azure Resource Manager (azurerm) as the backend.Low
gcsSpecifies Google Cloud Storage (gcs) as the backend.Low
remoteSpecifies a remote backend. You can use remote backends to run operations in HCP Terraform.Low
s3Specifies Amazon S3 (s3) as the backend.Low

Python

ExampleDescriptionComplexity
aws-lambda-end-to-endAn end-to-end example for a serverless web application hosted on AWS.High
awsProvisions an AWS Virtual Private Cloud (VPC).Low
aws-eksProvisions an EKS cluster on an AWS Virtual Private Cloud.Low
google-end-to-endAn end-to-end example for a serverless web application hosted on the Google Cloud Provider.High
azureProvisions a Virtual Network on Microsoft Azure.Low
dockerStarts a Docker container with an NGINX server.Low
kubernetesSchedules and exposes a NGINX deployment on a Kubernetes cluster.Low
ucloudProvisions a Linux base image on UCloud.Low

Java

Gradle

ExampleDescriptionComplexity
aws-gradleProvisions a DynamoDB table on the AWS provider.Low
azure-gradleProvisions a Virtual Network on Microsoft Azure.Low
google-gradleCreates a simple Compute Instance with the Google Cloud Platform Provider.Low
gradle-shared-moduleUses gradle to build and share two AWS modules. Modules are distinct configurations that you can package and reuse across projects and teams.Low
kubernetes-gradleSchedules and exposes a NGINX deployment on a Kubernetes cluster.Low
ucloud-gradleProvisions a Linux base image on UCloud.Low

Maven

ExampleDescriptionComplexity
aws-lambda-end-to-endAn end-to-end example for a serverless web application hosted on AWS.High
awsProvisions a DynamoDB table on the AWS provider.Low
azureProvisions a Virtual Network on Microsoft Azure.Low
google-end-to-endAn end-to-end example for a serverless web application hosted on the Google Cloud Provider.High
googleCreates a simple Compute Instance with the Google Cloud Platform Provider.Low
kubernetesSchedules and exposes a NGINX deployment on a Kubernetes cluster.Low
ucloudProvisions a Linux base image on UCloud.Low

C Sharp

ExampleDescriptionComplexity
awsProvisions a DynamoDB table on the AWS provider.Low
azureProvisions a Virtual Network on Microsoft Azure.Low
googleCreates a simple Compute Instance with the Google Cloud Platform Provider.Low
ucloudProvisions a Linux base image on UCloud.Low

Go

ExampleDescriptionComplexity
dockerStarts a Docker container with an NGINX server.Low
awsProvisions an EKS cluster on an AWS Virtual Private Cloud. High memory usage: The provider generation currently needs ~6 GB of memory, so the maximum for Node.js is currently set to 8GB.Low
google cloud kubernetes engine + kubernetesCreates a simple Compute Instance with the Google Cloud Platform Provider.Low
ucloudProvisions a Linux base image on UCloud.Low

Youtube Playlist

Release demos

Pocket public codebase

Mozilla Pocket is a widely used application for managing reading lists that is built into the Firefox browser. Like many Mozilla projects, Pocket is open source, and the CDK Terrain codebase that Pocket uses to manage infrastructure for the recommendation API is also public and open source. Pocket’s codebase provides a great example of how to lay out a CDK Terrain project. In order to re-use components, Pocket’s codebase is separated out into a set of reusable modules. These are then used from CDK Terrain code in the recommendation-api codebase. The recommended reading order is to:
  1. Read Pocket/recommendation-api/.aws/src/main.ts.
  2. Look at the constructs used that are defined in the Pocket/terraform-modules repository, such as PocketALBApplication.
  3. Look at the “base” constructs, which are are used in the higher-level constructs in the previous step.