:wave: Hi everyone! I'm rather new to Pulumi and a...
# general
b
👋 Hi everyone! I'm rather new to Pulumi and am hoping for an assist here. When attempting to deploy multiple instances of the same Pulumi program via a Next.JS API (in Typescript) with the Automation API, I run into this error for every concurrent cloud component in my stack:
Copy code
'failed to register new resource <INSERT_CLOUD_RESOURCE_NAME_HERE>: Resource monitor is terminating'
Additionally, I was able to see this error once, implying that there's only one instance of the engine running in my API:
Copy code
Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
To be sure, my deployment works just fine when the function is called once, further hinting at the notion that I'm referencing an already busy process. I'd love to know if there's a way to force Pulumi to spin up another process or instance whenever a new deployment is requested, but I could not find any documentation around it, so I'd love some pointers!
s
Hey there! I think you’re going to need to use multiple stacks here. Generally, to have multiple deployments of the same Pulumi program you need a separate stack for each deployment. You’ll probably need to modify your use of the Automation API to use separate stacks for each deployment.
b
Thanks for the reply, @salmon-account-74572. Apologies if I wasn't clear there. So the idea is that I am creating a new stack dynamically per request. They will all have a different StackName and ProjectName, but they hold the same infra components (a queue, a lambda, some roles and a mapping). That part seems to work well enough if I deploy them sequentially, but not if 2 or more requests hit my API at the same time. Currently, the way I'm doing it is by creating an
InlineProgramArgs
object based on information received from an HTTP POST, and then feeding that object into a
LocalWorkspace.createStack(args)
call. My expectation is that every time this is called, a new Stack instance is created for me. Am I offbase with this assumption?
e
The nodejs automation api can not run inline programs in parallel (we are looking into fixing this soon). Either lock around the call to createStack such that only one runs at a time, or use non-inline programs.
b
Thanks for the context, @echoing-dinner-19531. While this is unfortunate news, knowing the root cause was enough for me. Spinning it up using node's
fork
method seems to work fine enough. Less elegant, but working!
e
We do have an engineer looking into fixing this at the moment, working on the fix for python right now, but they'll look into nodejs after 🙂