This package has been deprecated

Author message:

WARNING: This project has been merged to @laconia/config. Install using @laconia/config to get the latest version.

@laconia/s3-config

0.11.0 • Public • Published

@laconia/s3-config

CircleCI Coverage Status Apache License

🛡️ Laconia S3 Config - Retrieves application config from S3

Features

  • Convention over configuration: Set environment variables and your application config will be made available in LaconiaContext

Install

npm install --save @laconia/s3-config

Usage

Set your lambda environment variable with LACONIA_S3CONFIG prefix:

LACONIA_S3CONFIG_MY_CONFIG: bucketName/path/to/config.json

config.json will be retrieved from S3, parsed, and made available as myconfig in your LaconiaContet:

const s3Config = require("@laconia/s3-config");
const laconia = require("@laconia/core");

const handler = async ({ myConfig }) => {
  // use myConfig
};

module.exports.handler = laconia(handler).register(s3Config.envVarInstances());

Only JSON file is supported at the moment.

IAM Permissions

Your Lambda is required to have IAM permissions for s3:GetObject action

API

s3Config.envVarInstances

Scan all environment variables that starts with LACONIA_S3CONFIG and return the derived instances. The object will automatically be parsed to javascript object. The name of the instances will be extracted from the environment variable name, then converted to camel case.

Example:

const s3Config = require("@laconia/s3-config");
const laconia = require("@laconia/core");

// LACONIA_S3CONFIG_MY_CONFIG env var will turn into myConfig
const handler = async ({ myConfig }) => {
  /* logic */
};

module.exports.handler = laconia(handler).register(s3Config.envVarInstance());

Package Sidebar

Install

npm i @laconia/s3-config

Weekly Downloads

1

Version

0.11.0

License

Apache-2.0

Unpacked Size

3.93 kB

Total Files

4

Last publish

Collaborators

  • tschoffelen
  • ceilfors