Skip to main content
tfts is a drop-in replacement for CDKTF. Migration requires updating imports and regenerating provider bindings.

Migration Steps

Step 1: Update Dependencies

Remove CDKTF packages and add tfts:

Step 2: Update Core Imports

Change imports from cdktf to tfts:

Step 3: Update Provider Imports

CDKTF uses pre-built provider packages (@cdktf/provider-*). tfts generates providers locally in .gen/.
Note: The relative path depth (../../../) depends on your file’s location relative to the project root.

Step 4: Regenerate Provider Bindings

This reads cdktf.json (or tfts.json) and generates TypeScript classes in .gen/.

Step 5: Update Configuration (Optional)

Rename cdktf.json to tfts.json if desired (both are supported):

Automated Migration

Save this script as migrate-from-cdktf.ts and run with bun migrate-from-cdktf.ts .:
The script converts:
  • from "cdktf"from "tfts"
  • from "constructs"from "tfts"
  • @cdktf/provider-X{relPath}/.gen/providers/hashicorp/X/index.js
  • @cdktf/provider-X/lib/Y{relPath}/.gen/providers/hashicorp/X/lib/Y/index.js

Import Path Reference

{relPath} = relative path from your file to project root (e.g., ../../.. for src/stacks/my-stack/)

API Compatibility

tfts maintains API compatibility with CDKTF core constructs:

Verification

After migration, verify the generated Terraform JSON is correct:

Troubleshooting

Import Errors

If you see import errors after migration, ensure:
  1. You ran npx tfts get to generate providers
  2. Provider imports use .js extension (ESM requirement)
  3. Provider paths match the structure in .gen/

Missing Providers

Add any missing providers to your config:
Then regenerate: npx tfts get