https://pulumi.com logo
Title
s

steep-caravan-65104

02/20/2020, 10:56 AM
Hi, we are trying to setup Pulumi in CI/CD with Google Cloud Build and encountered a weird issue where it is showing the following error about
Pulumi SDK has not been installed
even though we are indeed running
yarn install
. Can someone please help?
pulumi login <GCP Bucket address>
Logged into <GCP Bucket address>
pulumi preview --cwd=/workspace/identity --stack=identity-prod --refresh --non-interactive
Previewing update (identity-prod):
    pulumi:pulumi:Stack identity-identity-prod  error: It looks like the Pulumi SDK has not been installed. Have you run npm install or yarn install?
    pulumi:pulumi:Stack identity-identity-prod  1 message
Diagnostics:
  pulumi:pulumi:Stack (identity-identity-prod):
    error: It looks like the Pulumi SDK has not been installed. Have you run npm install or yarn install?
error: failed to load language plugin nodejs: could not read plugin [/usr/bin/pulumi-language-nodejs] stdout: EOF
Makefile:17: recipe for target 'ci-up' failed
make: *** [ci-up] Error 255
I'll add our setup's details (such as cloud build file etc.) in a thread to this comment.
Our setup is as follows: 1. root directory -> sub-directories, with one Pulumi project per sub-directory, e.g. one such sub-directory/Pulumi project is
identity
. 2. In Google Cloud Build, we are running cloud build steps from a
cloudbuild.yaml
file present in the sub-directory, i.e. from
identity/cloudbuild.yaml
. 3. The
identity/cloudbuild.yaml
file looks like the following:
steps:
  - name: "<http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>"
    args: [ "build", "-t", "<http://asia.gcr.io/$PROJECT_ID/|asia.gcr.io/$PROJECT_ID/><repo-name>:$COMMIT_SHA", "."]
  - name: "<http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>"
    args: ["push", "<http://asia.gcr.io/$PROJECT_ID/|asia.gcr.io/$PROJECT_ID/><repo-name>:$COMMIT_SHA"]
  - name: '<http://asia.gcr.io/$PROJECT_ID/|asia.gcr.io/$PROJECT_ID/><repo-name>:$COMMIT_SHA'
    entrypoint: /bin/bash
    args:
    - '-c'
    - "export BUILD_TYPE=${_BUILD_TYPE} && make ci-login && make ci-up"
    env:
      - 'PROJECT=identity'
      - 'ENV=prod'
    secretEnv: ["GOOGLE_CREDENTIALS"]
secrets:
  - kmsKeyName: <path-to-key>
    secretEnv:
      GOOGLE_CREDENTIALS: <REDACTED>
Note that do run
yarn install
in the Dockerfile:
FROM pulumi/pulumi

WORKDIR /workspace

COPY . .

# add other projects later
RUN yarn --cwd ./identity --frozen-lockfile install
And the
Makefile
(present in the root of the repo) has the following
make
commands called from the cloud build file above:
ci-login:
	pulumi login <path-to-bucket>

ci-up:
ifeq ($(BUILD_TYPE),preview)
	pulumi preview --cwd=$(PWD)/$(PROJECT) --stack=$(PROJECT)-$(ENV) --refresh --non-interactive
else
	pulumi up --cwd=$(PWD)/$(PROJECT) --stack=$(PROJECT)-$(ENV) --refresh --non-interactive
endif
_BUILD_TYPE
is specified with the value
preview
in the Google Cloud Build trigger configuration as per the official instructions from https://www.pulumi.com/docs/guides/continuous-delivery/google-cloud-build/
g

gentle-diamond-70147

02/20/2020, 4:00 PM
Is
$(PWD)/$(PROJECT)
in your Makefile the same path as
./identity
as in the Dockerfile?
You could add a
tree
or
ls -al node_modules
in one of them to help troubleshoot and see if the yarn install is installing to the expected location.
s

steep-caravan-65104

02/21/2020, 12:19 PM
Thanks, figured it out with your clues and by executing into the container. Basically, the issue was that the
node_modules
subdirectory was installed to the
/identity
directory of the docker container. But by default, Google Cloud Build mounts the host filesystem (without
node_modules
) to
/workspace
of the docker container and then the current working directory was specified as
/workspace
in the Dockerfile.
👍 1