Registry / aws / aws-lambda-env-modeler

aws-lambda-env-modeler

JSON →
library3.0.0pypypi✓ verified 85d ago

AWS-Lambda-Env-Modeler is a Python library (version 3.0.0, release cadence: irregular) that simplifies managing and validating environment variables in AWS Lambda functions using Python dataclasses, Pydantic models, or TypedDicts. It provides decorators and base classes to parse, validate, and cache environment configuration.

pip install aws-lambda-env-modeler
INSTALL
IMPORT
SIG · AWS-LAMBDA-ENV-MOD
A
aws-lambda-env-modeler
awspythonv3.0.0
Install
3.2s avg
Import
364ms
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.378s · 27.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.350s · 27MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseModel
from aws_lambda_env_modeler import BaseModel
from aws_lambda_env_modeler import LambdaEnvModel
v2 removed LambdaEnvModel; use BaseModel instead
parse_env
from aws_lambda_env_modeler import parse_env
correct import for the decorator
EnvModel
from aws_lambda_env_modeler import EnvModel
alias for BaseModel

Define an environment model using BaseModel, then decorate your Lambda handler with @parse_env. The parsed environment is attached to the context object. Alternatively, instantiate the model directly for testing.

import os from aws_lambda_env_modeler import BaseModel, parse_env class MyEnv(BaseModel): table_name: str stage: str = "dev" @parse_env(model_class=MyEnv) def lambda_handler(event, context): env = context.env # or use event['env'] print(f"Table: {env.table_name}, Stage: {env.stage}") return {"statusCode": 200} # For testing without Lambda context: os.environ['TABLE_NAME'] = 'my-table' os.environ['STAGE'] = 'prod' env = MyEnv() # directly instantiate print(env.table_name)
Debug
Known issues
breakingv3.0.0 drops Python 3.9 support (requires >=3.10). Pin to 2.1.0 if you need Python 3.9.
fix
Upgrade to Python 3.10+ or pin to aws-lambda-env-modeler==2.1.0
affects: >=3.0.0
deprecated`LambdaEnvModel` was removed in v2.0.0. Use `BaseModel` or `EnvModel` instead.
fix
Replace `LambdaEnvModel` with `BaseModel` from the same package.
affects: >=2.0.0
gotchaThe `parse_env` decorator uses LRU caching by default (via lru_cache). This can cause stale values in tests or when environment changes.
fix
Pass `use_cache=False` to `parse_env` in tests: `@parse_env(model_class=MyEnv, use_cache=False)`.
affects: >=1.0.7
gotchaEnvironment variables are parsed only once per process due to caching. If you change env vars at runtime, the model will not reflect the new values.
fix
Avoid changing env vars after the first invocation. If necessary, disable cache or use `force_refresh=True`.
affects: all
Errors
Common errors & fixes
AttributeError: module 'aws_lambda_env_modeler' has no attribute 'LambdaEnvModel'
`LambdaEnvModel` was removed in v2.0.0.
fix
Replace `LambdaEnvModel` with `BaseModel` or `EnvModel`.
TypeError: parse_env() got an unexpected keyword argument 'cache'
The `cache` parameter was renamed to `use_cache` in v1.0.7.
fix
Use `use_cache=False` instead of `cache=False`.
ImportError: cannot import name 'BaseModel' from 'aws_lambda_env_modeler'
The library is not installed or you are using an old version (<2.0.0).
fix
Install the latest version: `pip install --upgrade aws-lambda-env-modeler`. If on v1.x, use `from aws_lambda_env_modeler import LambdaEnvModel`.
Upgrade
Version history
3.0.0latest on PyPI · released Feb 27, 2026
Audit
Dependencies
pydanticoptionalDefault validation backend for dataclasses
aws-lambda-contextoptionalOptional integration for Lambda context
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
aws-lambda-env-modeler — pip install aws-lambda-env-modeler · libregistry