Skip to main content

A toolkit for serverless and AWS, with a focus on AWS Lambda and dynamodb.

Project description

Py aws Lambda Toolkit

This is a lightweight Python toolkit for easily and quickly creating AWS Lambda functions with the Serverless Framework. It includes the following features:

  • DynamoDB shortcuts: Avoid boilerplate code for DynamoDB operations.
  • HTTP event processing: Get the event of the HTTP request and parse it, splitting it into the path, query string, body, headers, etc.
  • HTTP response shortcuts: Create HTTP responses with the correct format and status code.
  • JWT authentication: Create and verify JWT tokens as easily as possible.
  • Logger: Log messages with a format that is easy to read.
  • Mappers: Remove specified fields from a dictionary or list of dictionaries.
  • Parser: Convert dictionary keys to snake case or camel case.
  • Password hashing: Hash passwords with salt and verify them.
  • DynamoDB scan builder: Build a scan query with specified filters.
  • Validator: Validate a dictionary with specified rules.

Installation

Install the package with pip:

pip install py-aws-lambda-toolkit

Usage

Use the package in your code:

import logging
from py_aws_lambda_toolkit.http_event import process_event
from py_aws_lambda_toolkit.http_response import create_response
from py_aws_lambda_toolkit.status_code import StatusCode
from py_aws_lambda_toolkit.logger import logging

status_code = StatusCode()

def handler(event, context):
    # Process the event
    event_data = process_event(event)
    event_body = event_data.get("body", {})

    logging.info("Event body: %s", event_body)

    # Create a response
    response = create_response(
        { "ok": True, "message": "Processed event successfully" },
        status_code=status_code.code_200_success,
    )

    return response

Contributing

Contributions are welcome! For bug reports or requests please submit an issue. For code contributions please create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Further Reading

This project is in an starting phase. More documentation will be added soon and the project will be improved with more features.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-aws-lambda-toolkit-0.0.4.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

py_aws_lambda_toolkit-0.0.4-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file py-aws-lambda-toolkit-0.0.4.tar.gz.

File metadata

  • Download URL: py-aws-lambda-toolkit-0.0.4.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for py-aws-lambda-toolkit-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fa27f02ad8fab3ad0c8dedcc6387f60672fece221d6be45bf995d9b266ec45f8
MD5 deeaf46ddfadc564d7df612f81742ba6
BLAKE2b-256 44433f03213ae867a562b75dc67b3f43916e163b5aa861003dfd238229e33a76

See more details on using hashes here.

File details

Details for the file py_aws_lambda_toolkit-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for py_aws_lambda_toolkit-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 65ae34ca73db2c7eeafc3ecfdbf91c4497a6c019ea57af5f4cfcbd490d5f1c6d
MD5 37ba8bbd7e0e99151446d0573709174a
BLAKE2b-256 87c2c05d7a224a1b539782bfaf83f9608644716b6caef5249f9aa25f14027a74

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page