Skip to main content

aws-json-dataset

Build codecov License: MIT Python 3.10

Lightweight and simple Python package to quickly send batches of JSON data to various AWS services.

Description

The idea behind this library is to create an easy, quick way to send JSON data to AWS services.

  • SQS
  • SNS
  • Kinesis Firehose
  • Kinesis Data Streams (coming soon)

JSON is an extremely common format and each AWS service has it's own API with different requirements for how to send data.

This library includes functionality for:

  • Automatically handling batch API calls to SNS, SQS and Kinesis Firehose
  • Manages available services based on record size
  • Base64 conversion for Kinesis streams

Roadmap

  • Support for Kinesis Data Streams
  • Support for DynamoDB inserts, updates and deletes
  • Support for S3, including gzip compression and JSON lines format
  • Support for FIFO SQS queues
  • Support for SNS topics

Quickstart

Set up your AWS credentials and environment variables and export them to the environment.

export AWS_PROFILE=<profile>
export AWS_REGION=<region>

Install the library using pip.

pip install -i https://test.pypi.org/simple/ aws-json-dataset

Send JSON data to various AWS services.

from awsjsondataset import AwsJsonDataset

# create a list of JSON objects
data = [ {"id": idx, "data": "<data>"} for idx in range(100) ]

# Wrap using AwsJsonDataset
dataset = AwsJsonDataset(data=data)

# Send to SQS queue
dataset.sqs("<sqs_queue_url>").send_messages()

# Send to SNS topic
dataset.sns("<sns_topic_arn>").publish_messages()

# Send to Kinesis Firehose stream
dataset.firehose("<delivery_stream_name>").put_records()

Local Development

Follow the steps to set up the deployment environment.

Prerequisites

  • AWS credentials
  • Python 3.10

Creating a Python Virtual Environment

When developing locally, create a Python virtual environment to manage dependencies:

python3.10 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install .[dev,test]

Environment Variables

Create a .env file in the project root.

AWS_REGION=<region>

Important: Always use a .env file or AWS SSM Parameter Store or Secrets Manager for sensitive variables like credentials and API keys. Never hard-code them, including when developing. AWS will quarantine an account if any credentials get accidentally exposed and this will cause problems. → Make sure that .env is listed in .gitignore

AWS Credentials

Valid AWS credentials must be available to AWS CLI and SAM CLI. The easiest way to do this is running aws configure, or by adding them to ~/.aws/credentials and exporting the AWS_PROFILE variable to the environment.

For more information visit the documentation page: Configuration and credential file settings

Unit Tests

Follow the steps above to create a Python virtual environment. Run tests with the following command.

coverage run -m pytest

Troubleshooting

  • Check your AWS credentials in ~/.aws/credentials
  • Check that the environment variables are available to the services that need them
  • Check that the correct environment or interpreter is being used for Python

Authors

Primary Contact: Gregory Christopher Lindsey (@chrisammon3000)

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Metadata

Release files for aws-json-dataset 0.1.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 aws-json-dataset 0.1.0
File Size Uploaded Provenance Actions
aws-json-dataset-0.1.0.tar.gz 50.4 kB Without provenance Details for aws-json-dataset-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aws-json-dataset 0.1.0
File Interpreter ABI Platform Actions
aws_json_dataset-0.1.0-py3-none-any.whl Python 3 none any Details for aws_json_dataset-0.1.0-py3-none-any.whl

Total release size: 63.2 kB

Release files / aws-json-dataset-0.1.0.tar.gz

Download URL aws-json-dataset-0.1.0.tar.gz
Size 50.4 kB
Tags Source
SHA-256 checksum
How to use checksums
17826833609c0b978a6101be1682c17115992400f36cebd2c6d0365a1918492b
BLAKE2b-256 checksum
How to use checksums
ee9aec3b20e8429b5a52f0b54829318b040a27512f04aabf5203152843b79efd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release files / aws_json_dataset-0.1.0-py3-none-any.whl

Download URL aws_json_dataset-0.1.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c7eb20585b2122485b675e2a845130efbd843b4ad2114a192bc4110b59e0c9b
BLAKE2b-256 checksum
How to use checksums
efcb8fcd2319790c01947f947d98fc6714af9faace2dc453844281c042c9c13b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Security for aws-json-dataset 0.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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