Laconia

Laconia

  • Getting Started
  • API
  • Help

›API Reference

Introduction

  • Getting Started
  • Motivation
  • Core Concepts
  • Philosophy
  • Examples
  • FAQ
  • Support Me

Laconia vs. Other

  • Claudia
  • Express, Koa, Hapi, etc.
  • Middy
  • Serverless, SAM, Apex, etc.

Guides

  • Injecting Dependencies
  • Unit Testing
  • Adapting Events
  • Creating API Endpoints
  • Retrieving Secrets
  • Retrieving Config
  • Warming Up
  • Invoking Other Lambdas
  • Long Running Tasks
  • Creating Middleware

API Reference

  • API Reference: Intro
  • core
  • event
  • adapter
  • adapter-api
  • invoker
  • config
  • batch
  • middleware-lambda-warmer
  • middleware-serverless-plugin-warmup
Edit

config

config.envVarInstances

Scan all environment variables that starts with LACONIA_CONFIG and return the derived values.

Example:

/**
 * Lambda Environment variables:
 * - LACONIA_CONFIG_SOME_SECRET: ssm://path/to/secret
 */
const config = require("@laconia/config");
const laconia = require("@laconia/core");

const app = async (input, { someSecret }) => {
  /* logic */
};

exports.handler = laconia(app).register(config.envVarInstances());

Environment variable convention

Key: LACONIA_CONFIG_[VARIABLE_NAME]

Value:

PrefixFormatExampleDescription
ssmssm:[parameter name]ssm:/path/to/my/secretRetrieves parameters and secrets from AWS SSM
secretsManagersecretsManager:[secret id]secretsManager:/path/to/my/secretRetrieves parameters and secrets from AWS Secrets Manager
s3s3:[bucket]/[key].jsons3:bucketName/path/to/config.jsonRetrieves application config from S3
booleanboolean:[truthy / falsy]boolean:offConverts truthy/falsy values to boolean
integerinteger:[an integer]integer:9000Converts integer values to true JS integers
floatfloat:[a float]float:1.345Converts float values to true JS floats

With boolean config, these are the falsy values which will be converted to false. If none of these values match, it will be converted to true:

  • "false"
  • "null"
  • "undefined"
  • "0"
  • "no"
  • "n"
  • "off"
  • "" (empty value)

With integer and float config variables, the passed values will be parsed if possible, otherwise NaN will be returned.

← invokerbatch →
  • config.envVarInstances
    • Environment variable convention
Laconia
Docs
Getting StartedCore ConceptsAPI Reference
Community
Stack OverflowChat
More
TwitterGitHubStar
Copyright © 2022 Wisen Tanasa
Logo designed by Suzie Nam