Search code examples
aws-cloudformationserverlessserverless-frameworkcircleci

CircleCI cannot find Serverless Framework after serverless installation


I'm trying to use Serverless Compose to deploy multiple services to AWS via CircleCI. I have 3 test services for a POC, and so far deploying these to a personal AWS account from the terminal works just fine. However, when I configure it to go through CircleCI with a config.yml file, I get this error:

Could not find the Serverless Framework CLI installation. Ensure Serverless Framework is installed before continuing.

I'm puzzled because my config.yml file looks like this:

version: 2.1
orbs:
  aws-cli: circleci/aws-cli@3.1.1
  serverless-framework: circleci/serverless-framework@2.0.0
  node: circleci/node@5.0.2

jobs: 
  deploy:
    parameters:
      stage: 
        type: string
    executor: serverless-framework/default
    steps:
      - checkout
      - aws-cli/install
      - serverless-framework/setup
      - run:
          command: serverless config credentials --provider aws --key $AWS_ACCESS_KEY_ID --secret $AWS_SECRET_ACCESS_KEY
          name: Configure serverless
      - run:
          command: npm install @serverless/compose
          name: Install @serverless/compose
      - run:
          command: serverless deploy --stage << parameters.stage >>
          name: Deploy staging

workflows:
  deploy-staging:
    jobs:
      - node/test:
          version: 17.3.0
      - deploy:
          context: aws-*******-developers
          name: ******-sandbox-use1
          stage: staging

The serverless framework is set up, the orb is present, but it says that it could not be found. All steps are successful until I get to deploy staging. I've been digging through documentation but I can't seem to find where it's going wrong with CircleCI. Does anyone know what I may be missing?


Solution

  • Turns out this required a weird fix, but it's best to remove the following:

    • The orb serverless-framework: circleci/serverless-framework@2.0.0
    • The setup step in the job - serverless-framework/setup
    • The Configure Serverless step

    Once these are removed, modify the Install @serverless/compose step to run npm install and install all the packages. Then run npx serverless deploy instead of serverless deploy. This fixed the problem for me.