@aws-lambda-powertools/parameters
Version:
The parameters package for the Powertools for AWS Lambda (TypeScript) library
37 lines (36 loc) • 1.42 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnvironmentVariablesService = void 0;
const commons_1 = require("@aws-lambda-powertools/commons");
const constants_js_1 = require("../constants.js");
class EnvironmentVariablesService extends commons_1.EnvironmentVariablesService {
// Environment variables
parametersMaxAgeVariable = 'POWERTOOLS_PARAMETERS_MAX_AGE';
ssmDecryptVariable = 'POWERTOOLS_PARAMETERS_SSM_DECRYPT';
/**
* It returns the value of the POWERTOOLS_PARAMETERS_MAX_AGE environment variable.
*
* @returns {number|undefined}
*/
getParametersMaxAge() {
const maxAge = this.get(this.parametersMaxAgeVariable);
if (maxAge.length === 0)
return undefined;
const maxAgeAsNumber = Number.parseInt(maxAge, 10);
if (Number.isNaN(maxAgeAsNumber)) {
console.warn(`Invalid value for ${this.parametersMaxAgeVariable} environment variable: [${maxAge}], using default value of ${constants_js_1.DEFAULT_MAX_AGE_SECS} seconds`);
}
else {
return maxAgeAsNumber;
}
}
/**
* It returns the value of the POWERTOOLS_PARAMETERS_SSM_DECRYPT environment variable.
*
* @returns {string}
*/
getSSMDecrypt() {
return this.get(this.ssmDecryptVariable);
}
}
exports.EnvironmentVariablesService = EnvironmentVariablesService;
;