UNPKG

@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.

42 lines (41 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnvironmentVariablesService = void 0; const commons_1 = require("@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 commons_1.EnvironmentVariablesService { // 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)); } } exports.EnvironmentVariablesService = EnvironmentVariablesService;