fetch-secret-identifier
v0.1.0
Published
Fetch AWS Secret Manager Identifier.
Downloads
104
Maintainers
Readme
Fetch Secret Identifier
Development
- Create the below environments in your .env(dotenv)
AWS_ACCESS_KEY=xxx
AWS_SECRET_KEY=xxx
DEV_ENV_PATH=xxx
AWS_REGION=xxxx
SM_REMOTE=true
DEV_ENV_PATH is your local environment configuration path, such as
${root}/config/environments/config.js
. If you do not set it, the default ispath.join(__dirname, './config/environments/config')
.AWS_REGION, default is
us-west-2
SM_REMOTE, if you want to debug local development, and want to access AWS Secret Manager. You could set SM_REMOTE as true. You could ignore by default.
Example
- getSecretValue
const sm = require('fetch-secret-identifier');
sm.getSecretValue('<your identifier>', (data) => {
// your code
});
- getSecretValueAsync
const sm = require('fetch-secret-identifier');
(async () => {
try {
// access your key in identifier
const { username, password, host } = await sm.getSecretValueAsync('ui/model-mysql/demo');
} catch (err) {
console.error(err);
}
})();