npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@corentind/aws-ssm-config

v0.3.1

Published

Fetch your configuration from AWS SSM Parameter store easily

Downloads

2

Readme

aws-ssm-config

Fetch your configuration from AWS SSM Parameter store easily

NPM Version Downloads Stats

This package comes from a refactoring problem that I had during a personal project. Basically, I stored by configuration on AWS SSM Parameter Store and wanted to retrieve it in a simple, type-safe and efficient way. So I made a simple package that I could reuse to make it easy and BOOM ! Here is aws-ssm-config !

Installation

npm install @corentind/aws-ssm-config

or if using Yarn :

yarn add @corentind/aws-ssm-config

Usage

Basic usage

import { SSMConfigClient } from '@corentind/aws-ssm-config';

// Create a client and provide the base path.
const client = new SSMConfigClient({
  basePath: '/myproject/api/prod'
});

// You can now retrieve parameters under this base path.
client.getByKey('mongo-url')
  .then(url => /* connect to MongoDB... */)
  .catch(error => console.error('Something went wrong : ', error));

On-fly decryption

import { SSMConfigClient } from '@corentind/aws-ssm-config';

const client = new SSMConfigClient({
  basePath: '/myproject/api/prod',
  withDecryption: true
});

client.getByKey('mongo-password')
  .then(password => /* SecureString is decrypted. */)
  .catch(error => console.error('Something went wrong : ', error));

XRay Tracing

import { SSMConfigClient } from '@corentind/aws-ssm-config';

// By specifying the `capture` option, all API calls will be captured by XRay.
const client = new SSMConfigClient({
  basePath: '/myproject/api/prod',
  capture: true
});

Overriding global options

import { SSMConfigClient } from '@corentind/aws-ssm-config';

const client = new SSMConfigClient({
  basePath: '/myproject/api/prod'
});

client.getByKey('common-prop', { basePath: '/myproject/common/prod' })
  .then(someProp => /* do something... */)
  .catch(error => console.error('Something went wrong : ', error));

Default configuration

import { SSMConfigClient } from '@corentind/aws-ssm-config';

// By providing a `config` object property, it will use the provided object instead of
// querying the SSM Parameter Store.
const client = new SSMConfigClient({
  basePath: '/myproject/api/prod',
  ...(process.env.NODE_ENV === 'local' && {
    config: {
      someServiceEndpoint: 'http://localhost:3030'    
    }
  })
});

client.getByKey('someServiceEndpoint')
  .then(serviceEndpoint => /* `http://localhost:3030`... */)
  .catch(error => console.error('Something went wrong : ', error));

Typescript support

import { SSMConfigClient } from '@corentind/aws-ssm-config';

// First, create a type for your configuration
interface MyConfig {
  someIntProperty: number;
}

// Then, create a client and provide the interface type parameter.
const client = new SSMConfigClient<MyConfig>({
  basePath: '/myproject/api/prod'
});

// You can now retrieve parameters in a type-safe fashion.
client.getByKey('someIntProperty')
  .then(anInt => /* anInt.toExponential() */)
  .catch(error => console.error('Something went wrong : ', error));

Development setup

The project was created and built with Yarn, so please use it too for development. Install dependencies :

yarn

Release History

  • 0.2.0
    • Added type-safe client
    • Added default configuration support
    • Removed capture parameter overrides
    • Updated documentation
  • 0.1.2
    • Fixed .npmignore
    • Updated NPM badges
  • 0.1.1
    • Added SSMClientConfig
    • Allows to retrieve one parameter at a time by key
    • Allows on-fly decryption
    • Allows XRay tracing

Meta

Corentin Delannoy – [email protected]

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/corentind59/aws-ssm-config)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request