# ssmble

> SSMble - a handy dandy config reader for AWS Parameter Store ------------------------------------------------------------

Latest version **2.0.0** (published 2024-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install ssmble
pnpm add ssmble
yarn add ssmble
bun add ssmble
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-03-05 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | cazoo-gitlab |

## Links

- npm: https://www.npmjs.com/package/ssmble
- npm.io page: https://npm.io/package/ssmble

## Dependencies (1)

- [@aws-sdk/client-ssm](https://npm.io/package/@aws-sdk/client-ssm.md) ^3.525.0

## Recent versions

- 2.0.0 (latest) — 2024-03-05
- 2.0.1-dev.3c5a67650 (next) — 2024-03-05
- 1.0.5-dev.741b068d2 — 2024-03-05
- 1.0.5-dev.7eb20b75f — 2022-02-01
- 1.0.4 — 2022-01-27
- 1.0.5-dev.0df0be8e1 — 2022-01-27
- 1.0.4-dev.a1350dc38 — 2022-01-27
- 1.0.4-dev.24bb34da2 — 2022-01-27
- 1.0.3-dev.1f4f1fbbd — 2022-01-27
- 1.0.3-dev.e5c8e87c5 — 2022-01-27
- 1.0.2-dev.44136b79f — 2022-01-27
- 1.0.1-dev.f227aecb1 — 2022-01-27
- 1.0.1-dev.3915d0d44 — 2022-01-27
- 1.0.1-dev.69e2438b9 — 2021-12-24
- 1.0.0 — 2021-09-03
- … 20 more at https://npm.io/package/ssmble/versions

## README

SSMble - a handy dandy config reader for AWS Parameter Store
------------------------------------------------------------

Here at Cazoo we recommend that applications fetch config at runtime from the
parameter store in SSM. This saves us from putting secrets into environment vars
and neatly separates config from deployment.

`ssmble` is a simple wrapper for the AWS SDK that makes building configuration simpler.

Usage
-----

Authoring a Configuration Template
===================================

SSMble works by mapping SSM parameters to the fields of an object literal.

Assuming the following parameters stored in SSM:

```
/my-service
   /secretText
   /options
     /name
     /age
   /bigness
   /isEnabled
```

We might choose to build the following configuration object.

```js
import { cfg } from 'ssmble'

// This template object describes the shape of our config
const template = {

  // the `str` function describes a required string
  secretText: cfg.str(),
  
  // the `int` function describes a required integer
  bigness: cfg.int(),
  
  // the bool function describes a required boolean
  isEnabled: cfg.bool(),
  
  // template objects nest
  options: {

    // each `cfg` function has a `maybe` equivalent that takes
    // optional default, and returns `undefined` if the value
    // is missing.
    name: maybeStr(),
    age: maybeInt( { default: 38 }),
  }
}
```

Fetching configuration
=====================

The `getConfig2` function makes the call to SSM and returns either a config object, or an Error result. The `Is` type provides type guards that let us check for success or failure in a type-safe way.

```js
import { getConfig2, Is } from 'ssmble'

export async function loadConfig() {
  
  const response = await getConfig2(template, '/my-service')
  
  if (Is.missingFields(response)) {
    throw new Error(`Failed to load config due to missing fields ${response.fields}`)
  }
  
  return result 
}
```

---
_Source: https://npm.io/package/ssmble · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
