This class is used to fetch environment variables that are available in the execution environment.

These variables can be a mix of runtime environment variables set by AWS and other environment variables that are set by the developer to configure Powertools for AWS Lambda.

import { EnvironmentVariablesService } from '@aws-lambda-powertools/commons/';

const config = new EnvironmentVariablesService();
const serviceName = config.getServiceName();

Implements

Constructors

Properties

devModeVariable: string = 'POWERTOOLS_DEV'

Increase JSON indentation for Logger to ease debugging when running functions locally or in a non-production environment

serviceNameVariable: string = 'POWERTOOLS_SERVICE_NAME'

Set service name used for tracing namespace, metrics dimension and structured logging

Methods

  • Get the value of the _X_AMZN_TRACE_ID environment variable.

    The AWS X-Ray Trace data available in the environment variable has this format: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=557abcec3ee5a047;Sampled=1,

    The actual Trace ID is: 1-5759e988-bd862e3fe1be46a994272793.

    Returns undefined | string

  • Helper function to determine if a value is considered falsy.

    Parameters

    • value: string

      The value to check for falsiness.

    Returns boolean