serverless-param-validate

0.1.3 • Public • Published

Serverless Param Validate

Serverless License NPM

A simple serverless v1.x plugin to give you a checking & validation capabilities to prevent unwanted execution!

This plugin allows a conditional input that will go through Eval function and if the result doesn't satisfy the condition, it will exit your serverless deployment to avoid unwanted mistakes.

Disclaimer

  • I'm building this plugin following my needs so i won't update the plugin if i don't need to, but feel free to open a PR if you think this plugin need enhancement.
  • I'm not an expert JS developer, so feel free to open PR if there are some codes that can be optimized.

Installation

npm install --save-dev serverless-param-validate

Usage

custom:
  validate:
    deploy:
      - cond: '"${self:provider.region}" == "ap-southeast-1"'
        error: Region must be ap-southeast-1
      - cond: '"${ssm:/architecture-type, ""}" == "verycool"'
        error: Infra type must be very cool. Please change it by fully delete and and redeploy the serverless again
    remove:
      - cond: '"${self:provider.region}" == "ap-southeast-1"'
        error: Region must be ap-southeast-1

Will give result such as:

❯ sls deploy --verbose --region=ap-southeast-1

Start param validation...
  CONDITION_0 - PASSED - "ap-southeast-1" == "ap-southeast-1"
✖ Validation error ("" == "verycool"): Infra type must be very cool. Please change it by fully delete and and redeploy the serverless again

2023 Randy Hermawan, GK

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i serverless-param-validate

      Weekly Downloads

      0

      Version

      0.1.3

      License

      MIT

      Unpacked Size

      6.83 kB

      Total Files

      5

      Last publish

      Collaborators

      • randyhermawan