env

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package env reads the environment variables Powertools is configured with.

The names and the accepted values are those of Powertools for AWS Lambda (Python), so that a function keeps its configuration when it moves from one runtime to the other. An explicit option always wins over the variable, which wins over the default.

Index

Constants

View Source
const (
	ServiceName = "POWERTOOLS_SERVICE_NAME"
	Dev         = "POWERTOOLS_DEV"
	Debug       = "POWERTOOLS_DEBUG"

	LogLevel          = "POWERTOOLS_LOG_LEVEL"
	LegacyLogLevel    = "LOG_LEVEL"
	LambdaLogLevel    = "AWS_LAMBDA_LOG_LEVEL"
	LambdaLogFormat   = "AWS_LAMBDA_LOG_FORMAT"
	LoggerSampleRate  = "POWERTOOLS_LOGGER_SAMPLE_RATE"
	LoggerLogEvent    = "POWERTOOLS_LOGGER_LOG_EVENT"
	LogDeduplication  = "POWERTOOLS_LOG_DEDUPLICATION_DISABLED"
	TracerCaptureResp = "POWERTOOLS_TRACER_CAPTURE_RESPONSE"
	TracerCaptureErr  = "POWERTOOLS_TRACER_CAPTURE_ERROR"
	TraceDisabled     = "POWERTOOLS_TRACE_DISABLED"
	TraceMiddlewares  = "POWERTOOLS_TRACE_MIDDLEWARES"

	MetricsNamespace    = "POWERTOOLS_METRICS_NAMESPACE"
	MetricsDisabled     = "POWERTOOLS_METRICS_DISABLED"
	MetricsFunctionName = "POWERTOOLS_METRICS_FUNCTION_NAME"
	DatadogFlushToLog   = "DD_FLUSH_TO_LOG"

	ParametersMaxAge     = "POWERTOOLS_PARAMETERS_MAX_AGE"
	ParametersSSMDecrypt = "POWERTOOLS_PARAMETERS_SSM_DECRYPT"

	IdempotencyDisabled    = "POWERTOOLS_IDEMPOTENCY_DISABLED"
	CircuitBreakerDisabled = "POWERTOOLS_CIRCUIT_BREAKER_DISABLED"

	LambdaFunctionName       = "AWS_LAMBDA_FUNCTION_NAME"
	LambdaFunctionVersion    = "AWS_LAMBDA_FUNCTION_VERSION"
	LambdaFunctionMemorySize = "AWS_LAMBDA_FUNCTION_MEMORY_SIZE"
	LambdaInitializationType = "AWS_LAMBDA_INITIALIZATION_TYPE"
	LambdaTaskRoot           = "LAMBDA_TASK_ROOT"
	LambdaMetadataAPI        = "AWS_LAMBDA_METADATA_API"
	LambdaMetadataToken      = "AWS_LAMBDA_METADATA_TOKEN" //nolint:gosec // G101: the name of a variable, not a credential
	Region                   = "AWS_REGION"
	XRayTraceID              = "_X_AMZN_TRACE_ID"
	SAMLocal                 = "AWS_SAM_LOCAL"
)

The variables every utility reads.

View Source
const DefaultServiceName = "service_undefined"

DefaultServiceName is the service of a function that does not name one, as Powertools Python calls it.

Variables

This section is empty.

Functions

func Bool

func Bool(name string, fallback bool) bool

Bool reads the variable name as a truth value, accepting what Powertools Python accepts: 1, y, yes, t, true, on and 0, n, no, f, false, off, in any case. An unset variable gives fallback; a value that is neither warns once and gives fallback too, so a typo never stops a function from starting.

func Float

func Float(name string, fallback float64) float64

Float reads the variable name as a number, or gives fallback.

func Get

func Get(name string) string

Get returns the value of the variable name, without surrounding spaces.

func IsDebug

func IsDebug() bool

IsDebug reports whether POWERTOOLS_DEBUG is on: Powertools writes down what it does internally.

func IsDev

func IsDev() bool

IsDev reports whether POWERTOOLS_DEV is on: utilities trade compactness for readability (pretty JSON logs, verbose errors).

func IsProvisioned

func IsProvisioned() bool

IsProvisioned reports whether the execution environment was initialized by provisioned concurrency, whose invocations never pay a cold start.

func MetricsOff

func MetricsOff() bool

MetricsOff reports whether metrics are switched off, with the rule Powertools Python applies to every metrics provider: POWERTOOLS_METRICS_DISABLED is true, or POWERTOOLS_DEV is on and POWERTOOLS_METRICS_DISABLED is unset. Setting POWERTOOLS_METRICS_DISABLED to false keeps metrics on in development mode.

func ParseBool

func ParseBool(raw string) (value, ok bool)

ParseBool parses a truth value the way Powertools Python's strtobool does.

func Seconds

func Seconds(name string, fallback time.Duration) time.Duration

Seconds reads the variable name as a whole number of seconds, or gives fallback.

func ServiceNameOr

func ServiceNameOr(fallback string) string

ServiceNameOr returns POWERTOOLS_SERVICE_NAME, or fallback when it is unset.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL