Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-dotenv-plugin

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-dotenv-plugin

Preload environment variables with dotenv into serverless.

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
130K
increased by2.64%
Maintainers
2
Weekly downloads
 
Created

What is serverless-dotenv-plugin?

The serverless-dotenv-plugin is a Serverless Framework plugin that automatically loads environment variables from a .env file into your serverless project. This allows you to manage environment-specific configurations and secrets in a centralized and secure manner.

What are serverless-dotenv-plugin's main functionalities?

Load Environment Variables

This feature allows you to load environment variables from a .env file into your serverless project. The code sample demonstrates how to configure the serverless-dotenv-plugin in the serverless.yml file and access an environment variable in a function.

module.exports = {
  service: 'my-service',
  plugins: ['serverless-dotenv-plugin'],
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x'
  },
  functions: {
    hello: {
      handler: 'handler.hello',
      environment: {
        MY_ENV_VAR: process.env.MY_ENV_VAR
      }
    }
  }
};

Custom .env File Path

This feature allows you to specify a custom path for your .env file. The code sample shows how to configure the plugin to load environment variables from a .env file located in a custom directory.

module.exports = {
  service: 'my-service',
  plugins: ['serverless-dotenv-plugin'],
  custom: {
    dotenv: {
      path: './config/.env'
    }
  },
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x'
  },
  functions: {
    hello: {
      handler: 'handler.hello',
      environment: {
        MY_ENV_VAR: process.env.MY_ENV_VAR
      }
    }
  }
};

Multiple Environment Files

This feature allows you to use different .env files for different environments. The code sample demonstrates how to configure the plugin to load environment variables from different .env files based on the environment.

module.exports = {
  service: 'my-service',
  plugins: ['serverless-dotenv-plugin'],
  custom: {
    dotenv: {
      path: {
        development: './config/.env.development',
        production: './config/.env.production'
      }
    }
  },
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x'
  },
  functions: {
    hello: {
      handler: 'handler.hello',
      environment: {
        MY_ENV_VAR: process.env.MY_ENV_VAR
      }
    }
  }
};

Other packages similar to serverless-dotenv-plugin

Keywords

FAQs

Package last updated on 19 Mar 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc