https://github.com/drudge/json-config-lambda-handler
Lambda function wrapper to load config from JSON environment variable (with optional KMS encryption)
https://github.com/drudge/json-config-lambda-handler
aws aws-lambda config environment-variables json kms lambda
Last synced: 3 months ago
JSON representation
Lambda function wrapper to load config from JSON environment variable (with optional KMS encryption)
- Host: GitHub
- URL: https://github.com/drudge/json-config-lambda-handler
- Owner: drudge
- Created: 2017-04-27T22:06:38.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-04-07T03:22:50.000Z (about 4 years ago)
- Last Synced: 2026-03-29T17:07:27.920Z (3 months ago)
- Topics: aws, aws-lambda, config, environment-variables, json, kms, lambda
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
json-config-lambda-handler
==========================
```js
const withConfig = require('json-config-lambda-handler');
function handleEvent({ event, config }, callback) {
console.log('event = ', event);
console.log('config = ', config);
callback(null);
}
exports.handle = withConfig(handleEvent);
```
## module.exports(handler)
* `handler` <[Function]> called when the handler is invoked
* `args` <[Object]>
* `event` <[Object]> AWS Lambda uses this parameter to pass in event data to the handler
* `context` <[Context Object]> AWS Lambda context object
* `config` <[Object]> parsed JSON configuration
* `callback` <[Function]> invoke to return info back to caller
* `error` <[Error]> an optional parameter that you can use to provide results of the failed Lambda function execution. When a Lambda function succeeds, you can pass null as the first parameter.
* `result` <[Object]> an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. If an error is provided, this parameter is ignored.
## module.exports(environmentVariable, handler)
* `environmentVariable` <[String]> an optional parameter containing environment variable name used to store the configuration. If not provided, a default value of `CONFIG` is used.
* `handler` <[Function]> called when the handler is invoked
* `args` <[Object]>
* `event` <[Object]> AWS Lambda uses this parameter to pass in event data to the handler
* `context` <[Context Object]> AWS Lambda context object
* `config` <[Object]> parsed JSON configuration
* `callback` <[Function]> invoke to return info back to caller
* `error` <[Error]> an optional parameter that you can use to provide results of the failed Lambda function execution. When a Lambda function succeeds, you can pass null as the first parameter.
* `result` <[Object]> an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. If an error is provided, this parameter is ignored.
[Function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
[Error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
[Context Object]: http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html