aws-secret-manager
A simple way to get a secret from AWS Secrets Manager.
Assumes that AWS credentials are set in .aws
or as Environment Variables.
install
yarn add @dsandor\aws-secret-manager
usage
const SecretManager = require('@dsandor\aws-secret-manager');
const secretManager = new SecretManager('my-secret-id');
const secret = await secretManager.getSecrets();
You can also pass the secret id on the getSecrets
call.
const SecretManager = require('@dsandor\aws-secret-manager');
const secretManager = new SecretManager();
const secret = await secretManager.getSecrets('my-secret-id');
Or one line if you wish;
const SecretManager = require('@dsandor\aws-secret-manager');
const secret = await new SecretManager().getSecrets('my-secret-id');
Constructor
SecretManager(secretName, region = process.env['AWS_REGION'] || process.env['AWS_DEFAULT_REGION'] || 'us-east-1')
getSecrets
async getSecrets(secretName = this.secretName)