This guide was recovered from the Wayback Machine snapshot of “Deploy Lambda functions with TypeScript and CDK for Terraform”.
TerraformAsset to package the Lambda deployment artifact.
Prerequisites
This tutorial assumes you are already familiar with the basic CDKTN workflow. If you are new to CDKTN, start with the install tutorial.- Terraform v1.2+ (or OpenTofu)
- CDKTN v0.15+
- AWS account
- AWS credentials configured for Terraform
- Node.js + npm
Explore CDKTN application
Clone the sample repository and move into the CDKTN project directory.Shell
View application stacks
Install dependencies.Shell
Shell
Shell
Deploy Hello World function
Deploy thelambda-hello-world stack.
Shell
url output in your browser to confirm the API gateway returns a greeting.
Deploy Hello Name function
Deploy thelambda-hello-name stack.
Shell
url output in your browser.
Append ?name=Terry to the URL to confirm the API gateway responds with a personalized greeting.
Inspect synthesized stacks
CDKTN generates acdktf.out directory when it synthesizes the Terraform configuration (during cdktn synth or cdktn deploy). Each stack has its own folder under cdktf.out/stacks.
cdktf.out/
terraform.lambda-hello-world.tfstate). Like any Terraform state file, do not commit state files into source control.
Clean up resources
Destroy both stacks to remove AWS resources.Shell
Shell
Next steps
- Continue with Deploy applications for an end-to-end, multi-step deployment workflow.
- Review how stacks work in CDKTN and Terraform state in Stacks.