npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-parent

v0.0.5

Published

Serverless plugin to share common configuration between services

Downloads

739

Readme

Serverless Parent Plugin

serverless npm version npm downloads license

Share common configuration between services

Requirements:

  • Serverless v1.12.x or higher.
  • AWS provider

How it works

Serverless Plugin that allows you to keep common configuration in a parent serverless.yml

Setup

Install via npm in the root of your Serverless service:

npm install serverless-plugin-parent --save-dev
  • Add the plugin to the plugins array in your Serverless serverless.yml:
plugins:
  - serverless-plugin-parent

Default Usage - Discover Serverless.yml

The plugin will recursively search all parent directories for a serverless.yml file until it reaches the user's home direcory or has gone x number of directories up. The default value is 3 but this can be configured using

custom:
  parent:
    maxLevels: 2     # Optional (Default 3)

Per default the parent file will overwrite settings in the service files. If you want the service file to have a higher priority you can change that using

custom:
  parent:
    overwriteServiceConfig: false     # Optional (Default true)
Project Structure
<project_root>
- service1
  - hello.js
  - serverless.yml
- service2
  - goodbye.js
  - serverless.yml
- serverless.yml
serverless.yml
provider:
  name: aws
  stage: ${opt:stage, "Test"}
  runtime: nodejs8.10
  role: DefaultRole

resources:
  Resources:
    DefaultRole:
      Type: AWS::IAM::Role
      Properties:
        Path: /
        RoleName: ${self:service}-${self:provider.stage}
        AssumeRolePolicyDocument:
          Version: "2012-10-17"
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - lambda.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: ${self:service}-${self:provider.stage}
            PolicyDocument:
              Version: "2012-10-17"
              Statement:
                - Effect: Allow
                  Action:
                    - logs:CreateLogGroup
                    - logs:CreateLogStream
                    - logs:PutLogEvents
                  Resource: arn:aws:logs:${self:provider.region}:*:log-group:/aws/lambda/*:*:*
service1/serverless.yml
service: Service1

plugins:
  - serverless-plugin-parent

provider:
  environment:
    HELLO_MESSAGE: Mholo

functions:
  Hello:
    handler: hello.handle
    events:
      - http:
          path: hello
          method: get
          cors: true
Effective serverless.yml

service: Service1

provider:
  name: aws
  stage: ${opt:stage, "Test"}
  runtime: nodejs8.10
  role: DefaultRole

plugins:
  - serverless-plugin-parent

provider:
  environment:
    HELLO_MESSAGE: Mholo

functions:
  Hello:
    handler: hello.handle
    events:
      - http:
          path: hello
          method: get
          cors: true

resources:
  Resources:
    DefaultRole:
      Type: AWS::IAM::Role
      Properties:
        Path: /
        RoleName: ${self:service}-${self:provider.stage}
        AssumeRolePolicyDocument:
          Version: "2012-10-17"
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - lambda.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: ${self:service}-${self:provider.stage}
            PolicyDocument:
              Version: "2012-10-17"
              Statement:
                - Effect: Allow
                  Action:
                    - logs:CreateLogGroup
                    - logs:CreateLogStream
                    - logs:PutLogEvents
                  Resource: arn:aws:logs:${self:provider.region}:*:log-group:/aws/lambda/*:*:*

Alternate Usage - Defined parent configuration path

Project Structure
<project_root>
- parent
  - serverless.yml
- service1
  - hello.js
  - serverless.yml
- service2
  - goodbye.js
  - serverless.yml
service1/serverless.yml
custom:
  parent:
    path: ../parent
    # or 
    path: ../parent/serverless.yml

Contribute

Help us making this plugin better and future proof.

  • Clone the code
  • Install the dependencies with npm install
  • Create a feature branch git checkout -b new_feature
  • Lint with standard npm run lint

License

This software is released under the MIT license. See the license file for more details.