# aws-param-store

> Library for loading parameters from AWS Parameter Store

Latest version **3.2.0** (published 2019-12-04) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install aws-param-store
pnpm add aws-param-store
yarn add aws-param-store
bun add aws-param-store
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2019-12-04 |
| First published | 2017-09-12 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/aws-param-store) |
| Module format | CommonJS |
| Node | >=8.10 |
| Dependencies | 0 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Vandium Software Inc. |
| Maintainers | richardhyatt |
| Keywords | AWS, SSM, secret, parameter store, parameter, store |

## Links

- npm: https://www.npmjs.com/package/aws-param-store
- Repository: https://github.com/vandium-io/aws-param-store
- Homepage: https://github.com/vandium-io/aws-param-store#readme
- Issues: https://github.com/vandium-io/aws-param-store/issues
- npm.io page: https://npm.io/package/aws-param-store

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.2.0 (latest) — 2019-12-04
- 4.0.0-Beta1 (beta) — 2020-01-26
- 3.1.0 — 2019-11-05
- 3.0.0 — 2019-05-18
- 2.1.0 — 2018-10-01
- 2.0.0 — 2018-04-03
- 1.1.0 — 2018-01-08
- 1.0.1 — 2017-09-13
- 1.0.0 — 2017-09-12

## README

[![Build Status](https://travis-ci.org/vandium-io/aws-param-store.svg?branch=master)](https://travis-ci.org/vandium-io/aws-param-store)
[![npm version](https://badge.fury.io/js/aws-param-store.svg)](https://badge.fury.io/js/aws-param-store)

# aws-param-store

Module for loading parameter-store values from AWS SSM

## Features
* Gets parameters by name(s) or path
* Recursively resolves paths and decodes parameters by default
* Paginates results automatically
* Supports both synchronous and asynchronous querying of parameters
* Uses Promises for asynchronous calls
* Can run inside AWS Lambda environment
* AWS Lambda Node.js 8.10.x compatible
* Lightweight and does not require additional dependencies other than the AWS-SDK


## Installation
Install via npm.

	npm install aws-param-store --save

**Note**: `aws-param-store` does not contain a dependency on `aws-sdk` and it should be installed within your application.

## Getting Started

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.getParametersByPath( '/project1/service1/production' )
    .then( (parameters) => {

        // do something here
    });
```

If your AWS region is not set in your environment variables, then it can be set programmatically by supplying
options when calling `newQuery()`:

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.getParametersByPath( '/project1/service1/production', { region: 'us-east-1' } )
    .then( (parameters) => {

        // do something here
    });
```

## API

### Overview

Most API method calls in this library have both asynchronous and synchronous versions.
When an asynchronous version is called, a Promise is returned to resolve the value
once the operation completes. When an `options` parameter is allowed, it can be used
to specify specific AWS service options such as the region. All of the
`getParameter*` methods will request that the values are decoded. If you require
further control, please use the `parameterQuery()` method.

### `getParameter( name [, options] )`

Gets a parameter by name. This method returns a promise that resolves the Parameter.

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.getParameter( '/project1/my-parameter', { region: 'us-east-1' } )
    .then( (parameter) => {

        // Parameter info object for '/project1/my-parameter'
    });
```

### `getParameterSync( name [, options] )`

Gets a parameter by name. This method will block until the operation completes.

```js
const awsParamStore = require( 'aws-param-store' );

let parameter = awsParamStore.getParameterSync( '/project1/my-parameter',
											{ region: 'us-east-1' } );

// Parameter info object for '/project1/my-parameter'
```


### `getParameters( names [, options] )`

Gets one or more parameters by name. This method returns a promise that resolves
an object that contains `Parameters` and `InvalidParameters`.

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.getParameters( ['/project1/my-parameter1', '/project1/my-parameter2'],
							 { region: 'us-east-1' } )
    .then( (results) => {

        // results.Parameters will contain an array of parameters that were found
		// results.InvalidParameters will contain an array of parameters that were
		//                           not found
    });
```

### `getParametersSync( names [, options] )`

Gets one or more parameters by name. This method will
block until the operation completes, and will return an object that contains
`Parameters` and `InvalidParameters`.

```js
const awsParamStore = require( 'aws-param-store' );

let results = awsParamStore.getParametersSync( ['/project1/my-parameter1', '/project1/my-parameter2'],
							     			   { region: 'us-east-1' } );

// results.Parameters will contain an array of parameters that were found
// results.InvalidParameters will contain an array of parameters that were
//                           not found
```

### `getParametersByPath( path [, options] )`

Gets parameters by recursively traversing the supplied path. This method returns
a promise that resolves the parameters that were found.

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.getParametersByPath( '/project1' )
    .then( (parameters) => {

		// parameters contains an array of parameter objects
    });
```

### `getParametersByPathSync( path [, options] )`

Gets parameters by recursively traversing the supplied path.  This method will
block until the operation completes, and will return a list of matching
parameters.

```js
const awsParamStore = require( 'aws-param-store' );

let parameters = awsParamStore.getParametersByPathSync( '/project1' );

// parameters contains an array of parameter objects
```

### `putParameter( name, value, type [, options] )`

Puts parameter. This method returns a promise that resolves to the version returned back.

```js
const awsParamStore = require( 'aws-param-store' );

awsParamStore.putParameter('key', 'value1,value2', 'StringList', {region: 'us-east-1', Overwrite: false})
    .then( (results) => {

		// results is the version of the value created
    });
```

### `putParameterSync( name, value , type [, options]  )`

Puts parameter. This method.  This method will block until the version returned back.

```js
const awsParamStore = require( 'aws-param-store' );

let results = awsParamStore.putParameterSync('key', 'securedstring', 'SecureString', {region: 'us-east-1'});

```

### `ParameterQuery`

Instances of `ParameterQuery` can be created by calling `parameterQuery( [options] )`.
This object is implementation behind the `getParameter*` methods, and allows further
control over how the calls are made to resolve parameters.

### `ParameterQuery.path( p )`

Sets the path name not be queried. Returns a reference to the `ParameterQuery`
instance.

### `ParameterQuery.named( name )`

Sets the name or names (if an array) to be queried. Returns a reference to the
`ParameterQuery` instance.

### `ParameterQuery.decryption( enabled = true )`

Indicates that the decryption of the values is enabled/disabled. Returns a
reference to the `ParameterQuery` instance.

### `ParameterQuery.recursive( enabled = true )`

Enables or disables recursive operations when resolving parameters by path.
Returns a reference to the `ParameterQuery` instance.

### `ParameterQuery.execute()`

Executes the query based on path or name(s) that were selected. Returns a Promise
that resolves the parameter results.

### `ParameterQuery.executeSync()`

Executes the query based on path or name(s) that were selected. This operation
will block until complete.


## Feedback

We'd love to get feedback on how to make this tool better. Feel free to contact
us at `feedback@vandium.io`

## License

[BSD-3-Clause](https://en.wikipedia.org/wiki/BSD_licenses)

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