serverless-plugin-select icon indicating copy to clipboard operation
serverless-plugin-select copied to clipboard

Serverless throw "unrecognized property: stages" warning

Open WANG-Lisa opened this issue 4 years ago • 1 comments

serverless: 2.41.2

New version of serverless can't read property stages, need to provide validation rule into constructor like this image

Could you please help to fix this issue in the plugin? thanks

WANG-Lisa avatar May 27 '21 05:05 WANG-Lisa

For anyone finding this, there is an open PR but in the mean time you can just create a local plugin to extend validation rules.

serverless.yml

plugins:
  - ./serverless-plugins/validation-rules # plugin-select incompatible with 2.x
  - serverless-plugin-select # allow function deployment to specific regions
  - ...

serverless-plugins/validation-rules.js

'use strict';

class ServerlessPlugin {
  constructor(serverless, options) {
    // from https://github.com/FidelLimited/serverless-plugin-select/pull/5/files
    serverless.configSchemaHandler.defineFunctionProperties(
      serverless.service.provider.name,
      {
        properties: {
          regions: { type: 'array', uniqueItems: true },
          stages: { type: 'array', uniqueItems: true },
        },
      }
    );
  }
}

module.exports = ServerlessPlugin;

benswinburne avatar Dec 11 '21 17:12 benswinburne