Skip to main content

Astromech - AWS Service Utilities for Lambda Functions

Astromech is a collection of utilities that I found myself copying all over my lambda functions and serverless projects. For the sake of DRYing up my code, I collected them in a single library.

Service Clients

Astromech implements lazy-initialization for Boto3 service clients:

For each service, there is a global client variable that gets reused between invocations of the labmda function container. Code that want access to the client achieves this by using a client() function that initializes it if necessary.

Code example:

from astromech import s3, dynamodb

s3.client().get_object(Bucket=..., Key=...)
dynamodb.table().get_item(Key=...)

LocalStack Support Made Easy

The service client initialization functions, look for the environment variable LOCALSTACK_[SERVICE]_URL (for example, LOCALSTACK_S3_URL). If it finds one, then it uses its value as the endpoint_url for the Boto3 client function.

All you have to do to run tests with LocalStack is to set these variables in your local environment. No changes to the code are necessary. Naturally, this works with any other downloadable version of AWS services, like DynamoDB local.

Utility Functions

There are a few utility functions in each service. These usually save 2-3 lines of boilerplate code. Not a lot, but for very common functionality that is repeated all across the code base, it becomes worthwhile.

For example, to check if an object exists on S3, you have to send a head_object request and catch the exception if it doesn't exist. With astromech.s3 you just call exists(bucket, key), much like you would do with a local file.

Why "Astromech"?

In the Star Wars universe, astromech is a type of utility droid, the most famous of which (whom?) is R2-D2.

Read more on Wookiepedia.

R2-series astromech droids

Metadata

Release files for astromech 0.5.0

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

Source distribution (sdist)

Source distribution for astromech 0.5.0
File Size Uploaded Provenance Actions
astromech-0.5.0.tar.gz 12.3 kB Without provenance Details for astromech-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for astromech 0.5.0
File Interpreter ABI Platform Actions
astromech-0.5.0-py3-none-any.whl Python 3 none any Details for astromech-0.5.0-py3-none-any.whl

Total release size: 23.2 kB

Release files / astromech-0.5.0.tar.gz

Download URL astromech-0.5.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
504ed50c4375a109f88c45b79cb86ce00d66572c2c37a258143523dcee8f3c42
BLAKE2b-256 checksum
How to use checksums
bf743b67e9e85949ffd93ba95a0bac0e6cc8ff86f39f16ca82baf7c519f7bed6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / astromech-0.5.0-py3-none-any.whl

Download URL astromech-0.5.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84c651c0268eda0f12186a1fecd7c79b1ddb4a188baddeaafd451f975e2c11ef
BLAKE2b-256 checksum
How to use checksums
b65ad46850199408d1435daea6e6f6afe31324e772b423e098459e5d6a01eedc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for astromech 0.5.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.

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