Is anyone running arbitrary NodeJS `child_process`...
# general
Is anyone running arbitrary NodeJS
functions (e.g.
) in their Pulumi applications? E.g. suppose you want to set up an SSH tunnel midway through a Pulumi process, after e.g. provisioning a bastion host, so rough pseudo code:
Copy code
const bastion = new cloudProvider.Instance(...)

spawnSync("ssh", ["-L", ...])

const database = new postgresql.Database(..., {
  host: "localhost" // the host is localhost because of the tunnel we've set up
I can see a few ways to go about this: 1. Use Pulumi automations, in which I orchestrate the "pre-tunnel" and "post-tunnel" bits. There's an example of this online, but I'm somewhat wary of this as I'd like to maintain access to the "standard" Pulumi CLI and its features if possible, which I understand automations would take me away from 2. "Just call the function" in the middle of the Pulumi program -- I think this is OK? Perhaps it needs wrapping in an
or something and feeding into another
? seems to suggest this is possible but the equivalent TypeScript code appears to be type incorrect (though I may be missing something obvious) 3. Use something like
, though since I want the tunnel to be created on every run, this feels wrong, since I'd not want it to go in the state file. But again, could be wrong here. All thoughts and input welcome/gratefully received 🙏
I'd recommend
. I haven't used it yet (I've only used local.Command), but it seems like you want remote.Command:
To make the command execute on every run, try:
I'd not seen
-- thanks!