Skip to main content

Lambda-Requests

https://img.shields.io/pypi/v/lambda_requests.svg

Lambda-requests use the well familiar requests library to access your HTTP enabled AWS Lambda functions.

Quick start

Installation

pip intall lambda-requests

Usage

>>> import lambda_requests
>>> lr = lambda_requests.Session()
>>> lr.get("http+lambda://flaskexp-test/test/foo")
<Response [200]>

In short, start a lambda_requests.Session() and then access you lambdas by passing http+lambda://{name-of-lambda-function}/… as the uri to the common requests methods such as get, post and the usual parameters such as query strings, form data and so on.

Lambda authorization is configured via boto3, and can be set up using environment variables or a configuration file. Configuration file is recommended. Example credential file ~/.aws/credentials:

[default]
aws_access_key_id =  XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Similar to authorization, region can be configured either via the environment variable AWS_DEFAULT_REGION, configuration file. Region can also be set on initialization of Session(region=”us-west-2”). Example configuration file ~/.aws/config:

[profile default]
region = us-west-2

The lambdas must support proxy integration, which is used commonly by frameworks such as Zappa, Mangum.

Why

In using REST microservice architecture it is important to be able to conveniently make calls from one service to another. To use this pattern in AWS serverless ecosphere along with Lambda one is practically forced to stand up an API Gateway in front of the lambda. This has several distinct disadvantages, all mostly along the lines of security.

  • API Gateway publicly exposes endpoints

  • API Gateway uses own authentication / authorization schema. While Lambda already supplies us with IAM.

  • Extra dependencies in call chain. While availability is high, latency may still be of concern.

Over all, to reduce exposure of private sub-services, re-use IAM authentication / authorization and reduce latency.

How does its work

Simple, we register a new protocol name with requests and use a lambda specific transport adapter which translates a requests request to lambda invoke compatible with AWS API Gateway simple proxy format.

Limitations

Following functionality has not been tested and is likely to not be functional:

  • Cookies

  • Basicauth

Metadata

Release files for lambda-requests 1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lambda-requests 1.5
File Size Uploaded
lambda_requests-1.5.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lambda-requests 1.5
File Interpreter ABI Platform
lambda_requests-1.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.1 kB

Release files / lambda_requests-1.5.tar.gz

Download URL lambda_requests-1.5.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cea67cbc5ebf8c8bc09de8c71ec6e4588365a77a44e9be70ee8c485bd3d95565
BLAKE2b-256 checksum
How to use checksums
0e03a7585d2d4634f65f75416641786797d3ec398e9f0c52094c45fad55f43e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / lambda_requests-1.5-py2.py3-none-any.whl

Download URL lambda_requests-1.5-py2.py3-none-any.whl
Size 5.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9897792e247f3eee3bec18753a6883e1a3e31b5c3ae2efbb692908a1e245af1e
BLAKE2b-256 checksum
How to use checksums
7db3dab7280fa7f506fbd48c1cbbc2f6b50ea73e08c29e07e62f4950dc59e305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

1.5 This release

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.9

2 release files

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page