question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recent update in serverless CLI broke serverless.ts deployment

See original GitHub issue

sls deploy in a Serverless TS project no longer works. It’s looking for serverless.yml instead of serverless.ts. My project worked fine in 2.35.0, and since upgrading to 2.37.1, this bug has reared its head. As a test, I went into another project of mine that uses serverless-typescript and upgraded it to 2.37.1, but the issue didn’t occur. So there’s some combination of packages of settings that’s causing this.

Temporary workaround for anyone reading this: sls deploy -c serverless.ts

serverless.ts
import type { AWS } from '@serverless/typescript';
import * as migrationStepFunction from './src/step-functions/migration-step-function.asl.json';
import sqsResources from './resources/sqs';

const serverlessConfiguration: AWS & { stepFunctions: any } = {
  service: 'migrate-user',
  frameworkVersion: '2',
  custom: {
    env: '${file(./settings-${self:provider.stage}.json)}',
    userPoolId: '${cf:backend-${self:provider.stage}.UserPoolId}',
    userPoolArn: '${cf:backend-${self:provider.stage}.UserPoolArn}',
    chargebeeSite: {
      dev: 'xx-test',
      prod: 'xx',
    },
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true,
    },
  },
  package: {
    individually: true,
  },
  plugins: ['serverless-webpack', 'serverless-step-functions'],
  provider: {
    name: 'aws',
    runtime: 'nodejs12.x',
    memorySize: 256,
    timeout: 10,
    // @ts-ignore
    logRetentionInDays: '${self:custom.env.LOG_RETENTION_DAYS}',
    stage: '${opt:stage, "dev"}',
    tracing: {
      lambda: true,
    },
    versionFunctions: false,
    apiGateway: {
      minimumCompressionSize: 1024,
      shouldStartNameWithService: true,
    },
    environment: {
      NODE_OPTIONS: '--enable-source-maps',
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
      MONGO_URL: '${ssm:/prod/v1MongoUrl~true}',
      DB_ARN: '${cf:backend-${self:provider.stage}.DatabaseArn}',
      DB_NAME: '${cf:backend-${self:provider.stage}.DatabaseName}',
      DB_SECRET_ARN: '${self:custom.env.RDS_SECRET_ARN}',
    },
    iamRoleStatements: [
      {
        Effect: 'Allow',
        Action: ['cognito-idp:AdminCreateUser', 'cognito-idp:AdminGetUser'],
        Resource: '${self:custom.userPoolArn}',
      },
      {
        Effect: 'Allow',
        Action: [
          'rds-data:ExecuteSql',
          'rds-data:ExecuteStatement',
          'rds-data:BatchExecuteStatement',
          'rds-data:BeginTransaction',
          'rds-data:RollbackTransaction',
          'rds-data:CommitTransaction',
        ],
        Resource: '*',
      },
      {
        Effect: 'Allow',
        Action: 'secretsmanager:GetSecretValue',
        Resource: '*',
      },
      {
        Effect: 'Allow',
        Action: 'lambda:InvokeFunction',
        Resource:
          'arn:aws:lambda:us-east-1:xx:function:' +
          'upload-processor-${self:provider.stage}-uploadProcessor',
      },
      {
        Effect: 'Allow',
        Action: 'sqs:SendMessage',
        Resource: {
          'Fn::Sub': '${FileMigrationQueue.Arn}',
        },
      },
    ],
  },
  functions: {
    checkUser: {
      handler: 'src/lambda/check-user.handler',
    },
    createAccount: {
      handler: 'src/lambda/create-account.handler',
      environment: {
        USER_POOL_ID: '${self:custom.userPoolId}',
        CHARGEBEE_SITE: '${self:custom.chargebeeSite.${self:provider.stage}}',
        CHARGEBEE_API_KEY:
          '${ssm:/${self:provider.stage}/chargebee/apiKey~true}',
      },
    },
    migrateFolders: {
      handler: 'src/lambda/migrate-folders.handler',
    },
    migrateTracks: {
      handler: 'src/lambda/migrate-tracks.handler',
      memorySize: 2048,
      environment: {
        SQS_QUEUE_URL: {
          Ref: 'FileMigrationQueue',
        },
      },
    },
    migrateImages: {
      handler: 'src/lambda/migrate-images.handler',
      environment: {
        SQS_QUEUE_URL: {
          Ref: 'FileMigrationQueue',
        },
      },
    },
    migrateReels: {
      handler: 'src/lambda/migrate-reels.handler',
    },
    migrationQueueProcessor: {
      handler: 'src/lambda/migration-queue-processor.handler',
      environment: {
        UPLOAD_PROCESSOR_FUNC:
          'upload-processor-${self:provider.stage}-uploadProcessor',
      },
      events: [
        {
          sqs: {
            arn: {
              'Fn::GetAtt': ['FileMigrationQueue', 'Arn'],
            },
          },
        },
      ],
    },
  },
  stepFunctions: {
    noOutput: true,
    stateMachines: {
      migrateStepFunction: {
        name: 'migrateUser-${self:provider.stage}',
        definition: migrationStepFunction,
      },
    },
  },
  resources: {
    Parameters: {
      Stage: {
        Type: 'String',
        Default: '${self:provider.stage}',
      },
    },
    Conditions: {
      ProductionEnv: {
        'Fn::Equals': [
          {
            Ref: 'Stage',
          },
          'prod',
        ],
      },
    },
    Outputs: {
      StateMachineArn: {
        Value: {
          Ref: 'MigrateUserDash${self:provider.stage}',
        },
      },
    },
    Resources: {
      ...sqsResources,
    },
  },
};

module.exports = serverlessConfiguration;
sls deploy output
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
             - ServerlessWebpack for "out"
             - ServerlessStepFunctions for "name", "data", "path", "stage", "region"
            Please report this issue in plugin issue tracker.
            Starting with next major release, this will be communicated with a thrown error.
            More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Deprecation warning: Syntax for referencing SSM parameters was upgraded with automatic type detection and there's no need to add "~true" or "~split" postfixes to variable references.
            Drop those postfixes and set "variablesResolutionMode: 20210326" in your service config to adapt to a new behavior.
            Starting with next major release, this will be communicated with a thrown error.

            More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_VARIABLES_RESOLVER
Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
              "provider.iamRoleStatements" -> "provider.iam.role.statements"
            More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS

 Error ---------------------------------------------------

  Error: ENOENT: no such file or directory, open '/Volumes/SuperData/Sites/xx/v2-migrate-user/serverless.yml'
      at Object.openSync (fs.js:462:3)
      at Object.readFileSync (fs.js:364:35)
      at readFileSync (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/serverless/lib/utils/fs/readFileSync.js:7:24)
      at Utils.readFileSync (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/serverless/lib/classes/Utils.js:78:12)
      at YamlParser.parse (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/serverless/lib/classes/YamlParser.js:12:40)
      at fromYamlFile (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/serverless-step-functions/lib/yamlParser.js:14:74)
      at ServerlessStepFunctions.yamlParse (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/serverless-step-functions/lib/yamlParser.js:25:12)
      at ServerlessStepFunctions.tryCatcher (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/Volumes/SuperData/Sites/xx/v2-migrate-user/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:461:21)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.20.1
     Framework Version:         2.37.1 (local)
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.9.0

Installed version

Serverless: Running "serverless" installed locally (in service node_modules)
Framework Core: 2.37.1 (local)
Plugin: 4.5.3
SDK: 4.2.2
Components: 3.9.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ffxsamcommented, Apr 22, 2021

I just saw here (https://github.com/dherault/serverless-offline/issues/1172) that you and @medikoo have authorship access to serverless-offline. That’s awesome! Thank you both.

Hopefully serverless-webpack is fixed soon. Currently, all developers using this have to pin it to 5.3.5 in order for function deployment to work at all.

0reactions
pgrzesikcommented, Apr 22, 2021

Hello @ffxsam - we’re trying to help out at the moment when it comes to plugin support. We plan to select the most important ones and ensure that they’re working well with next major version. serverless-offline has been recently released with Node14 support and I’m personally slowly getting up to speed with that plugin from development/maintenance perspective.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to Serverless Framework v3
Serverless Framework v3 contains a few breaking changes that may impact some projects. This guide helps users upgrade from Serverless Framework v2 to...
Read more >
Create a Serverless App on AWS using TypeScript — Part 1
The serverless framework locally invokes the hello function and runs the exported hello method in the handler. ts file. The serverless invoke ...
Read more >
Datadog Serverless Framework Plugin
You may encounter the error of missing type definitions. To resolve the error, add datadog-lambda-js and dd-trace to the devDependencies list of your...
Read more >
Using the Serverless Toolkit with TypeScript - Twilio
New TypeScript Twilio Serverless project from Twilio CLI ... When you run npm start or npm run deploy the project will automatically be...
Read more >
serverless | Yarn - Package Manager
⚠ BREAKING CHANGES. Read the complete v3 Upgrade Guide. ... AWS Lambda: Default lambda hashing algorithm was changed to 20201221; Runtimes nodejs10.x ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found