Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

serverless-cli-v3

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

serverless-cli-v3

Yalo serverless CLI v3

unpublished
latest
Source
npmnpm
Version
3.0.0-beta.2
Version published
Maintainers
1
Created
Source

Yalo Serverless CLI

This tool was created to optimize the creation time of client specific integrations and to define a standard in file and folder structures.

  • config.js
  • serverless.yml
  • lambdas
  • unit-tests

It also accelerates the exchange of knowledge with other teams in other parts of the world 🌎. This update of the tools makes goes in hand with the update of flow to Studio-NG

Usage

ysc [options] [command]

Options

-V, --version       output the version number
-h, --help          output usage information

Commands ysc (Current)

init                Create a new base project for serverless (lambdas)
add-lambda          Create a new base lambda scripts for the serverless (with its respective unit-test)
generate [options]  Generate the following files: serveless.yml, README.md, docs.md

Help

init

Usage: init [options]

Create a new base project for serverless (lambdas)

Options:
  -h, --help  output usage information

add-lambda

Usage: add-lambda [options]

Create a new base lambda scripts for the serverless (with its respective unit-test)

Options:
  -h, --help  output usage information

generate

Usage: generate [options]

Generate the following files: serveless.yml, README.md, docs.md

Options:
  -s --stage <stage>  Serverless stage (staging or production) (default: "staging")
  --no-serverless     Do not generate the serverless.yml
  -h, --help          output usage information

Serverless Settings

In order to generate the serverless.yml file with all lambdas' settings (environment vars, secrets, networking configs, etc), it is required to place those configurations on the yalo-config.json file.

Supported settings

Currently it is possible to map the following features from the yalo-config.json file to the serverless.yml (the one generated by the CLI generate command):

  • Runtime - Sets the NodeJS runtime version.
  • Networking - Sets AWS pre-existent Security Groups and Subnets (VPC).
  • Standard Env Vars - Defines non-sensitive environment variables on global and function scopes, by stage.
  • Secret Env Vars - Defines sensitive environment variables on global and function scopes, by stage. Those must be created beforehand on SSM, with the following naming convention: /${project-prefix}/${stage}/${var-name}.
  • Customer - Alias of the customer for which the lambdas project is. Example: aeromexico, femsa-mx, pepsico-ch, etc. This is mainly for identifying a group of lambda functions' performance/health on Datadog. It is suggested to put as an slugified version of the customer's name, and maybe also the country code if it's a global account.

yalo-config.json example

{
  "aws": {
    "service": "MyServerlessProjectService",
    "prefix": "my-serverless-project",
    "customer": "my-customer",
    "region": "us-east-1",
    "runtime": "nodejs10.x",
    "vpc": {
      "securityGroups": [
        "sg-05a7c1fa7e055cc89"
      ],
      "subnets": [
        "subnet-0494f36d5918a3d0b",
        "subnet-02603079c20f46758"
      ]
    },
    "envVars": {
      "globals": {
        "staging": {
          "myGlobalVar": "myGlobalVarStagingValue"
        },
        "production": {
          "myGlobalVar": "myGlobalVarProdValue"
        }
      },
      "functions": {
        "do-something": {
          "staging": {
            "myDoSomethingVar": "myDoSomethingVarStagingValue"
          },
          "production": {
            "myDoSomethingVar": "myDoSomethingVarProdValue"
          }
        }
      }
    },
    "ssmVars": {
      "globals": [
        "myGlobalSSMVar", "myOtherGlobalSSMVar"
      ],
      "functions": {
        "do-something": [
          "myDoSomethingSSMVar"
        ]
      }
    }
  }
}

Dynamic Tagging

The generate command will set any custom tag defined on a lambda function inside the serverless.yml file definition.

To set any custom tag, you need to add it on your lambda function metadata variable. Like the following:

...
const metadata = {
  description: 'My lambda function description',
  timeout: 180,
  tags: [
    { key: 'datadog', value: true },
    { key: 'yalo-feature', value: 'my-feature' },
  ],
}
...
const handler = async (event, context, callback) => {
  ...
  // handler code
  ...
}
...
module.exports = {
  handler,
  metadata,
  schema,
}

Gathering current AWS settings

The task of making the yalo-config.json file with all lambdas' configurations can get somewhat tedious, particularly on projects with several lambda functions.

To help you a little with this, you can get a concentrate of all your project's settings by using the backup-lambdas script. That concentrate might be handy to identify all the Serverless settings that need to be mapped to the yalo-config.json file.

Keywords

yalo

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts