@aws-lambda-powertools/idempotency
Version:
The idempotency package for the Powertools for AWS Lambda (TypeScript) library. It provides options to make your Lambda functions idempotent and safe to retry.
39 lines (38 loc) • 1.5 kB
JavaScript
import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';
/**
* Class EnvironmentVariablesService
*
* This class is used to return environment variables that are available in the runtime of
* the current Lambda invocation.
* These variables can be a mix of runtime environment variables set by AWS and
* variables that can be set by the developer additionally.
*
* @class
* @extends {CommonEnvironmentVariablesService}
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables
*/
class EnvironmentVariablesService extends CommonEnvironmentVariablesService {
// Reserved environment variables
functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME';
idempotencyDisabledVariable = 'POWERTOOLS_IDEMPOTENCY_DISABLED';
/**
* It returns the value of the AWS_LAMBDA_FUNCTION_NAME environment variable.
*
* @returns {string}
*/
getFunctionName() {
return this.get(this.functionNameVariable);
}
/**
* It returns whether the idempotency feature is enabled or not.
*
* Reads the value of the POWERTOOLS_IDEMPOTENCY_DISABLED environment variable.
*
* @returns {boolean}
*/
getIdempotencyEnabled() {
return !this.isValueTrue(this.get(this.idempotencyDisabledVariable));
}
}
export { EnvironmentVariablesService };