Python Lambda Context
A micro library that provides the AWS Lambda Context class for type checking and testing.
Installing
pip install aws-lambda-context
Usage
Import the LambdaContext on your handler file and type hint the lambda function with it:
from aws_lambda_context import LambdaContext
def my_lambda_handler(event: Any, context: LambdaContext) -> None:
...
The type hint should enables type checking with mypy and editor auto-completion
The class is also useful as a mock during tests:
from aws_lambda_context import (
LambdaClientContext,
LambdaClientContextMobileClient,
LambdaCognitoIdentity,
LambdaContext
)
def test_handler():
lambda_cognito_identity = LambdaCognitoIdentity()
lambda_cognito_identity.cognito_identity_id = 'cognito_identity_id'
lambda_cognito_identity.cognito_identity_pool_id = 'cognito_identity_pool_id'
lambda_client_context_mobile_client = LambdaClientContextMobileClient()
lambda_client_context_mobile_client.installation_id = 'installation_id'
lambda_client_context_mobile_client.app_title = 'app_title'
lambda_client_context_mobile_client.app_version_name = 'app_version_name'
lambda_client_context_mobile_client.app_version_code = 'app_version_code'
lambda_client_context_mobile_client.app_package_name = 'app_package_name'
lambda_client_context = LambdaClientContext()
lambda_client_context.client = lambda_client_context_mobile_client
lambda_client_context.custom = {'custom': True}
lambda_client_context.env = {'env': 'test'}
lambda_context = LambdaContext()
lambda_context.function_name = 'function_name'
lambda_context.function_version = 'function_version'
lambda_context.invoked_function_arn = 'invoked_function_arn'
lambda_context.memory_limit_in_mb = 'memory_limit_in_mb'
lambda_context.aws_request_id = 'aws_request_id'
lambda_context.log_group_name = 'log_group_name'
lambda_context.log_stream_name = 'log_stream_name'
lambda_context.identity = lambda_cognito_identity
lambda_context.client_context = lambda_client_context
assert handler({}, lambda_context) == 'something'
References
Metadata
Release files for aws-lambda-context 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aws-lambda-context-1.1.0.tar.gz | 2.5 kB | Without provenance | Details for aws-lambda-context-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aws_lambda_context-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for aws_lambda_context-1.1.0-py3-none-any.whl |
Total release size: 6.1 kB
Release files / aws-lambda-context-1.1.0.tar.gz
| Download URL | aws-lambda-context-1.1.0.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6a6d3360671b25bb171335c7e6510b22e60c6fd5db99803f478c986d3230220
|
|
BLAKE2b-256 checksum How to use checksums |
8de2792aa5b62ff3f38b574774457304a53f85bc851e00b80cb547faf03c724b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Release files / aws_lambda_context-1.1.0-py3-none-any.whl
| Download URL | aws_lambda_context-1.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d03b16aaf8abac30b71bc5d66ed8edadd8805e0d581f73f1e9b4b171635c817d
|
|
BLAKE2b-256 checksum How to use checksums |
53d66b42e7999b6659158390378d009b04366fa7150d9d337b402072f067a7b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Security for aws-lambda-context 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.