I'm trying to deploy a Node.js service to the clou...
# automation-api
m
I'm trying to deploy a Node.js service to the cloud containing a Pulumi program and trigger it via the service API. The cloud console logs the following error when triggered:
Copy code
/workspace/node_modules/.pnpm/@pulumi+pulumi@3.146.0_typescript@5.7.3/node_modules/@pulumi/pulumi/automation/errors.js:81
: new CommandError(result);
^
CommandError: code: -2
stdout:
stderr: Command failed with ENOENT: pulumi version
spawn pulumi ENOENT
err?: Error: Command failed with ENOENT: pulumi version
spawn pulumi ENOENT
at Object.createCommandError (/workspace/node_modules/.pnpm/@pulumi+pulumi@3.146.0_typescript@5.7.3/node_modules/@pulumi/pulumi/automation/errors.js:81:23)
at /workspace/node_modules/.pnpm/@pulumi+pulumi@3.146.0_typescript@5.7.3/node_modules/@pulumi/pulumi/automation/cmd.js:204:28
[...]
Do I need to install the Pulumi CLI into the container image as well or is the npm package
@pulumi/pulumi
already self-contained? The docs on Embedding Pulumi with the Automation API suggest you do not need the CLI installed, however the Get started with Automation API lists it under prerequisites (assuming it's required?). A web search did not really reveal any helpful advice with that issue. Can someone help? 🙂
m
You do need the CLI, the Automation API is essentially a wrapper around it
From the implementation it seems that the Automation API code can also handle the installation of the CLI. But if you run in a container, I think it makes sense to include a specific CLI version as part of the image.
Not sure if it helps, here's a snippet from one of my Dockerfiles that installs Pulumi and adds it to the PATH so that the Automation API can find it:
Copy code
WORKDIR /

ENV PATH="${PATH}:/root/.pulumi/bin"

RUN apt-get update && \
    apt-get install curl --no-install-recommends -y && \
    curl -fsSL <https://get.pulumi.com> | sh && \
    echo "${PATH}" && which pulumi && pulumi version
k
You can also check these base images out https://hub.docker.com/r/pulumi/pulumi-nodejs
m
I now use the
pulumi/pulumi-nodejs
image and it works flawlessly! Thanks a lot, @kind-motherboard-59197 and @modern-zebra-45309 🙂👍