Middy: Secrets Manager middleware

Created on 6 Apr 2018  路  6Comments  路  Source: middyjs/middy

In the same vein as the SSM middleware, a middleware for the newly anounced Secrets Manager would be really useful.

Here are the aws-sdk docs: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SecretsManager.html#getSecretValue-property

Most helpful comment

I have created AWS Secrets Manager as a middy-secrets package:

https://www.npmjs.com/package/middy-secrets
Repository: https://github.com/hsz/middy-secrets

Example usage:

import middy from 'middy';
import secrets from 'middy-secrets';

const fn = () => {
  console.log('process.env', process.env);
  // contains secrets from AWS Secrets Manager
};

const handler = middy(fn)
  .use(secrets({
    region: 'eu-west-1',
    secretName: 'dev/mySecrets',
  }));

module.exports = { handler };

Any comments/PRs are welcome!

All 6 comments

I have created AWS Secrets Manager as a middy-secrets package:

https://www.npmjs.com/package/middy-secrets
Repository: https://github.com/hsz/middy-secrets

Example usage:

import middy from 'middy';
import secrets from 'middy-secrets';

const fn = () => {
  console.log('process.env', process.env);
  // contains secrets from AWS Secrets Manager
};

const handler = middy(fn)
  .use(secrets({
    region: 'eu-west-1',
    secretName: 'dev/mySecrets',
  }));

module.exports = { handler };

Any comments/PRs are welcome!

Awesome job @hsz! I'd say we should probably add a section on the main README to list all the non-official middlewares

@lmammino that's great to hear.
I also have to thank for the middy! For a year I was using my custom, less complex wrapper, but middy fulfills my requirements and gives even more, good job! :)

Hi @hsz I added a PR to switch from ES6 exports to node module.exports so that it works out of the box with lambda + middy without having to use any transpilers:

https://github.com/hsz/middy-secrets/pull/2

@dankelleher Thanks! I've merged it and published with v.0.2.1

@lmammino I think that this issue can be successfuly closed.
@dschep secretsMiddleware has been added to the middy

FYI - just marked my middy-secrets as deprecated.

Was this page helpful?
0 / 5 - 0 ratings