Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ Serverless Helpers (Node.js Version)
* Helps your modules locate and load Stage Variables that the Serverless framework adds on deployment.
* Allows access to the CF Output variables that you defined in the `s-resources-cf.json` file.

## Access environment variables
After loading your `.env` file's environment variables with
```
var ServerlessHelpers = require('serverless-helpers-js');
ServerlessHelpers.loadEnv();
```

You can access them through `process.env`. For example, if you define database info in your `.env`:
```
var dbConnection = mysql.createConnection({
host: process.env.databaseServer,
user: process.env.databaseUser,
password: process.env.databasePassword,
database: process.env.database
});
```

## CF Output variables
To have your lambda access the CF output variables you have to give it the `cloudformation:describeStacks` access rights in the lambda IAM role.

Expand Down