Fetch AWS Secret Manager Identifier.
npm install fetch-secret-identifier1. Create the below environments in your .env(dotenv)
``.env`
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 is path.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.
- getSecretValue
`js`
const sm = require('fetch-secret-identifier');
sm.getSecretValue('
// your code
});
- getSecretValueAsync
`js
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);
}
})();
``