Skip to content

Commit

Permalink
issue-1 - Can specify multiple environment variable keys to decrypt m…
Browse files Browse the repository at this point in the history
…ultiple at once
  • Loading branch information
aceew committed Jan 27, 2017
1 parent fd6c131 commit 0dd4bcd
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports.handler = (event, context, callback) => {

## API Reference

### Get an encrypted variable
### Decrypt an environment variable that uses a custom KMS key
Uses KMS to decrypt the cipher text stored under the environment variable of the specified key name. Caches the decrypted variable in the global scope so it is only decrypted once per container, cutting down on KMS decryption costs.

```javascript
Expand All @@ -76,6 +76,23 @@ Parameters:

Returns a promise that resolves the decrypted value, or rejects an error if there were issues connecting to KMS or issues with the encrypted payload.

### Decrypt multiple environment variables that use a custom KMS key
Like the single variable, uses KMS to decrypt the cipher text stored under keys in the `process.env` object (Lambda environment variables). Again, the decrypted values are cached in the global scope, so the variables are only encrypted once per Lambda container. Multiple environment variable keys can be specified and they will be returned as keys to an object where the values are decrypted.

```javascript
lambdaEnvVars.getCustomDecryptedValueList(['envVarKey1', 'envVarKey2']);
// returns { envVarKey1: 'Decrypted variable', envVarKey2: 'Decrypted variable' }
```

Parameters:

| Name | Type | Default | Info |
| --- | --- | --- | --- |
| variableNames | Array | [] | Keys in process.env to which encrypted environment variables are stored under. |

Returns an object containing the decrypted values where the keys are the items specified in the params `variableNames`.


### Get an environment variable decrypted using a default service key
Returns the variable stored under `process.env` for the specified key. Default service key encrypted variables are decrypted before the Lambda invocation meaning the decrypted value is already available under `process.env`.

Expand All @@ -88,7 +105,8 @@ Parameters:
| --- | --- | --- | --- |
| variableName | string | '' | The key in process.env to which the variable is stored under. |

Returns the string value of the environment variable. No decryption takes plae in code as this is done before Lambda is called.
Returns the string value of the environment variable. No decryption takes place in code as this is done before Lambda is called.


## Notes
- In order to use the decryption feature you'll have to set a KMS encryption key on your lambda function.
Expand Down

0 comments on commit 0dd4bcd

Please sign in to comment.