Note
Maintenance mode. HashiCorp sunset CDKTF and archived hashicorp/terraform-cdk on 2025-12-10 (last release 0.21.0). cdktf-injector keeps supporting cdktf >=0.20.3 <0.22 with bug and security fixes only. No new features are planned.
cdktf-injector is a dependency injection library for CDKTF (AWS Cloud Development Kit for Terraform).
If you are not familiar with cdktf and terraform yet or haven't heard of them before, this library may not be that so useful. That's totally cool, but I recommend you to have a look what they (cdktf and terraform) are or at least what's the concept of IaC. Those are really amazing.
There are two prerequisites for cdktf-injector
-
Terraform - Terraform must be on your
PATH. See the Terraform install guide. -
cdktf - A library for defining Terraform resources using programming constructs. Click here to get started. Or, simply type the following lines.
mkdir your-project-name cd your-project-name npx cdktf-cli init --template="typescript" --local
- No decorator
- No need to declare custom classes
- No need to explicitly write dependencies
Using npm
npm install cdktf-injector --saveUsing pnpm
pnpm add cdktf-injectorUsing yarn
yarn add cdktf-injector| Package | Version |
|---|---|
| Node.js | >= 22 |
| cdktf (peer) | >=0.20.3 <0.22 |
| constructs (peer) | ^10.3.0 |
Note : cdktf supports multiple languages, such as
TypeScript,Python,Java,C#andGo. However, according to Typescript restriction of jsii, which I originally wanted to use to power my lib and what cdktf depends on, it does not allow usingParameterized Types(aka: Generics). And as far as I know, there is no other decent way to implement dependency injection without using generics or decorators. In brief,cdktf-injectoris currently available only in Node.js env. I'm looking forward to making this lib support multiple languages soon.
The project is managed by projen with pnpm. Edit .projenrc.ts and run pnpm projen instead of editing generated files (package.json, tsconfig*.json, workflows, ...).
pnpm install
pnpm build # compile, test, package
pnpm test # jest + eslint
pnpm docgen # TypeDoc into docs/The devcontainer (.devcontainer/) installs Node.js and Terraform (via the ghcr.io/devcontainers/features/terraform feature).
docs/ is TypeDoc output regenerated by pnpm docgen; do not edit it by hand. Work items are tracked as markdown under issues/, not GitHub Issues.