cdktf-cli
: Invoke Terraform CLI with node:child_process
instead of node-pty
. (Bun + Deno support)
#3675
Labels
cdktf-cli
: Invoke Terraform CLI with node:child_process
instead of node-pty
. (Bun + Deno support)
#3675
Description
Issue
cdktf-cli
currently uses@cdktf/node-pty-prebuilt-multiarch
to spawn a child process that runs the Terraform CLI fordeploy
anddestroy
commands (docs). This is a fork ofnode-pty
for providing pre-built binaries as it has native/C components.This currently has some sharp edges:
postinstall
lifecycle script doesn't correctly trigger (may happen with alternative package managers like pnpm or Bun).postinstall
) by default because they're a security vulnerability (remote code execution).node-gyp
like in Bun support microsoft/node-pty#632.node-pty
uses some V8-specific APIs which can cause problems for alternative runtimes that don't use V8 as the JavaScript engine.node-pty
effectively creates a hard dependency on the Node.js runtime (Node.js API + V8 JavaScript engine) and other pre-compiled binaries which creates a narrow compatibility window and an extra maintenance burden.Proposal
One option is to use Node's
child_process.spawn()
(docs) to spawn child processes. Setting thestdio
option (docs) toinherit
seems to allow use of interactive child processes like the Terraform CLI.This removes the need for binaries outside of the JavaScript runtime, leaving only a dependency on the Node.js API.
Alternative JavaScript runtimes typically provide polyfills for Node.js APIs. In particular, both Bun and Deno provide
node:child_process
polyfills, removing the need forcdktf-cli
to use each runtime's idiomatic child process spawning APIs.Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: