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-env-stage-config

v1.3.8

Published

Serverless plugin to define environment variables files for stages

Downloads

1,367

Readme

serverless-plugin-env-stage-config

npm version XO code style

This Serverless plugin allows to define environment variable configuration files for stages. It exposes a new variable resolver ($esc) that automatically picks the correct value based on the selected stage. For development stages (local, dev, development), the variables will default to the system’s environment variables.

CI

Tests Release

Installation

pnpm add -D serverless-plugin-env-stage-config
plugins:
  - serverless-plugin-env-stage-config

Usage

For non-development stages, the variables will be retrieved from a serverless.env.${stage}.yml file, alongside the serverless.yml.

Let’s consider the following serverless.yml:

name: my-service

useDotenv: true

resources:
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: some-queue

provider:
  name: aws

  environment:
    MYSQL_HOST: ${esc:MYSQL_HOST}
    MYSQL_PORT: ${esc:MYSQL_PORT}

functions:
  run-something:
    handler: handler.run
    environment:
      QUEUE_URL: ${esc:QUEUE_URL}
      SECRET_TOKEN: ${esc:SECRET_TOKEN}

Local stages

In a local environment, the variables resolved with the esc: prefix will be equivalent to using env:. Using useDotenv: true alongside a .env file will alow you to define your environement variables.

The supported local stages are:

  • local
  • dev
  • development

Other stages

If you need to define a different source for the environement variables for your prod stage, you can define a serverless.env.prod.yml to redefine the variables.

For example, if you’re using AWS SSM Parameter Store, you could create the following file:

MYSQL_HOST: ${ssm:/my-service/prod/MYSQL_HOST}
QUEUE_URL: !Ref MyQueue
SECRET_TOKEN: ${ssm:/my-service/prod/SECRET_TOKEN}

Any variable that is not included in the serverless.env.prod.yml file will produce a warning and fallback to using env:. In this case, you will get the following warning:

Serverless: env-stage-config: WARNING: the MYSQL_PORT variable is not defined in serverless.env.prod.yml, defaulting to ${env:MYSQL_PORT, null}.

If a variable is not defined in the stage environment configuration file, or the environment (process.env), it will default to null.

License

MIT

Miscellaneous

    ╚⊙ ⊙╝
  ╚═(███)═╝
 ╚═(███)═╝
╚═(███)═╝
 ╚═(███)═╝
  ╚═(███)═╝
   ╚═(███)═╝