lambee
Version:
A tool to help developer work with AWS Lambda.
30 lines (24 loc) • 1.64 kB
JavaScript
const listParams = require('./listParams')
/**
* Registers this CLI action with Commander.
*
* @param {*} program An instance of Commander CLI library
*/
function registerAction(program) {
program
.command('paramlist')
.description('Prints the names and descriptions of our params stored in AWS SSM. Typically this will be for secret config like passwords and keys. Note, this function does not give you the config values.')
.option('--profile <profile>', 'The AWS profile. You can set this using environment variable AWS_PROFILE.')
.option('--region <region>', 'The AWS region. You can set this using environment variable AWS_DEFAULT_REGION.')
.option('-c, --cache', 'Cache results locally. Makes repeated execution much quicker on slow networks. Will not pick up changes to the functions list though.')
.option('-v, --verbose', 'Prints the full object returned by AWS SDK instead of just the function name.')
.option('-d, --debug', 'Enable debug logging')
.action((cmdObj) => {
const profile = cmdObj.profile || process.env.AWS_PROFILE
const region = cmdObj.region || process.env.AWS_DEFAULT_REGION
if (!profile) return console.error('AWS profile not set. Use --profile option or AWS_PROFILE environment variable.')
if (!region) return console.error('AWS region not set. Use --region option or AWS_DEFAULT_REGION environment variable.')
listParams(cmdObj.cache, profile, region, cmdObj.verbose, cmdObj.debug).then(console.log).catch(console.log)
})
}
module.exports = { registerAction }