A utility library for common AWS services
Project description
๐ aws-util
A comprehensive Python utility library wrapping 100+ AWS services with sync/async parity, Pydantic models, and production-grade error handling.
๐ Table of Contents
- โจ Features
- ๐๏ธ Architecture
- ๐ Project Structure
- โ๏ธ Prerequisites
- ๐ Quick Start
- ๐ Usage
- ๐ง Configuration
- ๐งช Testing
- ๐ CI/CD
- ๐ Changelog
- ๐ค Contributing
- ๐ License
โจ Features
- ๐ 135 Service Modules โ Typed wrappers for S3, SQS, DynamoDB, Lambda, Bedrock, ECS, and 100+ more AWS services with 7,300+ method wrappers
- โก Full Async Parity โ Every sync function has a native
async defcounterpart inaws_util.aio.*using a custom aiohttp engine (no monkey-patching) - ๐ก๏ธ Structured Exception Hierarchy โ
AwsThrottlingError,AwsNotFoundError,AwsPermissionError, etc. replace genericRuntimeErrorwhile staying backward-compatible - ๐ฆ Pydantic Result Models โ Every API response is returned as an immutable
BaseModel, not a raw dict - ๐ TTL Client Cache โ Bounded LRU cache (64 entries, 15-min TTL) auto-rotates STS credentials in long-running processes
- ๐ Multi-Service Orchestration โ Pre-built modules for blue/green deployments, data lake management, cross-account operations, disaster recovery, and CI/CD pipelines
- ๐ ๏ธ Lambda Middleware โ Idempotency, batch processing, timeout guards, cold-start tracking, and feature flags out of the box
- ๐ Security & Compliance โ Least-privilege analysis, secret rotation, data masking, VPC auditing, WAF management, and compliance snapshots
- ๐ Observability โ Structured logging, X-Ray tracing, EMF metrics, CloudWatch alarms, and automated dashboard generation
๐๏ธ Architecture
graph TB
subgraph App["๐ฅ๏ธ Your Application"]
Sync["Sync API<br/>aws_util.*"]
Async["Async API<br/>aws_util.aio.*"]
end
subgraph Core["โ๏ธ Core Layer"]
Client["_client.py<br/>TTL LRU Cache"]
Engine["aio/_engine.py<br/>aiohttp Transport"]
Errors["exceptions.py<br/>Error Hierarchy"]
end
subgraph Services["โ๏ธ AWS Services (135 modules)"]
S3["S3 ยท SQS ยท SNS"]
DB["DynamoDB ยท RDS ยท ElastiCache"]
Compute["Lambda ยท ECS ยท EKS ยท Batch"]
AI["Bedrock ยท SageMaker ยท Rekognition"]
Security["IAM ยท KMS ยท Secrets Manager"]
More["+ 100 more services"]
end
subgraph Orchestration["๐ Multi-Service Orchestration"]
Deploy["Deployment & Blue/Green"]
DataLake["Data Lake & ETL"]
Resilience["Resilience & Circuit Breaker"]
Observe["Observability & Monitoring"]
end
Sync -->|boto3| Client
Async -->|aiohttp + SigV4| Engine
Client --> Services
Engine --> Services
Errors -.->|classifies| Services
Services --> Orchestration
๐ Project Structure
๐ฆ aws-util/
โโโ ๐ src/aws_util/ # 138 sync modules
โ โโโ ๐ __init__.py # Top-level convenience imports
โ โโโ โ๏ธ _client.py # TTL-aware boto3 client factory
โ โโโ ๐จ exceptions.py # Structured error hierarchy
โ โโโ ๐ aio/ # 137 async counterparts
โ โ โโโ โ๏ธ _engine.py # Native aiohttp async engine
โ โ โโโ ๐ *.py # One async module per service
โ โโโ ๐ s3.py # S3 operations
โ โโโ ๐ dynamodb.py # DynamoDB operations
โ โโโ ๐ lambda_.py # Lambda management
โ โโโ ๐ bedrock.py # Bedrock AI services
โ โโโ ๐ blue_green.py # Blue/green deployments
โ โโโ ๐ data_lake.py # Data lake management
โ โโโ ๐ observability.py # Monitoring & logging
โ โโโ ๐ ... (125+ more) # All other service modules
โโโ ๐ tests/ # 276 test files, 100% coverage
โโโ ๐ .github/workflows/ # 20 CI/CD workflows
โโโ โ๏ธ pyproject.toml # Build config & task runner
โโโ โ๏ธ Pipfile # Dependency management
โโโ ๐ README.md
graph LR
Root["๐ฆ aws-util"] --> Src["๐ src/aws_util"]
Root --> Tests["๐งช tests (276 files)"]
Root --> GH["๐ .github/workflows"]
Src --> SyncMods["๐ 135 sync modules"]
Src --> AIO["๐ aio/"]
AIO --> AsyncMods["๐ 137 async modules"]
AIO --> Engine["โ๏ธ _engine.py"]
SyncMods -->|"1:1 parity"| AsyncMods
โ๏ธ Prerequisites
Before you begin, make sure you have the following installed:
| Tool | Version | Install |
|---|---|---|
| Python | โฅ 3.10 | python.org |
| pip | โฅ 21.x | Comes with Python |
| pipenv | Latest | pip install pipenv |
| AWS CLI | โฅ 2.x | aws.amazon.com/cli |
| taskipy | Latest | Installed via dev deps |
๐ก Tip: Configure AWS credentials via
aws configureor environment variables (AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION).
๐ Quick Start
1. Clone the repository
git clone https://github.com/Masrik-Dahir/aws-util-python.git
cd aws-util-python
2. Install dependencies
pip install -e .[dev]
# Or with pipenv:
PIPENV_IGNORE_VIRTUALENVS=1 pipenv install --dev
3. Install from PyPI (library usage)
pip install aws-util
4. Use it โ Sync
from aws_util.s3 import upload_file, download_bytes, list_objects
from aws_util.dynamodb import get_item, put_item
from aws_util.sqs import send_message, receive_messages
# Upload a file to S3
upload_file("my-bucket", "data/report.csv", "/tmp/report.csv")
# Query DynamoDB
item = get_item("users-table", {"pk": "user#123"})
# Send an SQS message
send_message("my-queue", {"event": "order.placed", "id": "abc"})
5. Use it โ Async
from aws_util.aio.s3 import upload_file, download_bytes
from aws_util.aio.dynamodb import get_item, put_item
async def main():
await upload_file("my-bucket", "key.csv", "/tmp/data.csv")
item = await get_item("users-table", {"pk": "user#123"})
๐ Usage
Placeholder Resolution (SSM + Secrets Manager)
from aws_util import retrieve
# Resolves SSM parameters and Secrets Manager secrets
db_url = retrieve("{{ssm:/prod/db/url}}")
api_key = retrieve("{{secret:prod/api-key}}")
Multi-Service Orchestration
from aws_util.deployer import deploy_lambda_with_config, deploy_ecs_from_ecr
from aws_util.data_pipeline import run_glue_then_query, export_query_to_s3_json
from aws_util.security_ops import audit_public_s3_buckets, rotate_iam_access_key
from aws_util.blue_green import ecs_blue_green_deployer
Lambda Middleware
from aws_util.lambda_middleware import (
idempotent_handler, batch_processor, middleware_chain,
lambda_timeout_guard, cold_start_tracker, lambda_response,
)
Event-Driven Orchestration
from aws_util.event_orchestration import (
create_eventbridge_rule, saga_orchestrator, fan_out_fan_in,
create_schedule, run_workflow,
)
Resilience & Error Handling
from aws_util.resilience import circuit_breaker, retry_with_backoff, dlq_monitor_and_alert
from aws_util.exceptions import AwsThrottlingError, AwsNotFoundError
try:
item = get_item("table", {"pk": "key"})
except AwsNotFoundError:
print("Resource not found")
except AwsThrottlingError:
print("Rate limited โ retrying")
Observability
from aws_util.observability import (
StructuredLogger, create_xray_trace, emit_emf_metric,
create_lambda_alarms, generate_lambda_dashboard,
)
Security & Compliance
from aws_util.security_compliance import (
least_privilege_analyzer, secret_rotation_orchestrator,
data_masking_processor, compliance_snapshot,
)
Cost Optimization
from aws_util.cost_optimization import (
lambda_right_sizer, unused_resource_finder,
concurrency_optimizer, cost_attribution_tagger,
)
AI/ML Pipelines
from aws_util.ai_ml_pipelines import (
bedrock_serverless_chain, s3_document_processor,
image_moderation_pipeline, translation_pipeline,
)
All 135 Service Modules
Click to expand full module list
| Category | Modules |
|---|---|
| Storage | s3, efs, fsx, storage_gateway |
| Database | dynamodb, rds, rds_data, documentdb, elasticache, memorydb, neptune, neptune_graph, redshift, redshift_data, redshift_serverless, keyspaces, timestream_write, timestream_query |
| Compute | lambda_, ecs, ecr, ec2, eks, batch, app_runner, autoscaling, elastic_beanstalk, emr, emr_containers, emr_serverless, lightsail |
| Messaging | sqs, sns, ses, ses_v2, eventbridge, kinesis, firehose, msk, messaging |
| AI/ML | bedrock, bedrock_agent, bedrock_agent_runtime, comprehend, rekognition, textract, translate, transcribe, polly, personalize, personalize_runtime, forecast, forecast_query, sagemaker_runtime, sagemaker_featurestore_runtime, lex_models, lex_runtime |
| Security | iam, kms, secrets_manager, cognito, cognito_identity, access_analyzer, detective, inspector, macie, security_hub, sso_admin |
| Networking | route53, acm, cloudfront, elbv2, vpc_lattice |
| Management | cloudwatch, cloudtrail, cloudformation, config_service, organizations, health, service_quotas |
| Developer Tools | codebuild, codecommit, codedeploy, codepipeline, codeartifact, codestar_connections |
| Analytics | athena, glue, databrew, quicksight, kinesis_analytics |
| IoT | iot, iot_data, iot_greengrass, iot_sitewise |
| Media | connect, ivs, mediaconvert |
| Migration | dms, transfer |
| Orchestration | stepfunctions, event_orchestration, data_flow_etl, data_pipeline, blue_green, deployer, deployment, disaster_recovery, container_ops, ml_pipeline, networking, cross_account, data_lake, database_migration, credential_rotation, cost_governance, cost_optimization, security_automation, security_compliance, security_ops, infra_automation, resilience, observability, resource_ops, config_loader, config_state, event_patterns, lambda_middleware, api_gateway, notifier, messaging, ai_ml_pipelines, testing_dev |
| Core | _client, exceptions, placeholder, parameter_store, sts |
๐ง Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
AWS_ACCESS_KEY_ID |
โ | โ | AWS access key |
AWS_SECRET_ACCESS_KEY |
โ | โ | AWS secret key |
AWS_DEFAULT_REGION |
โ | us-east-1 |
Default AWS region |
AWS_SESSION_TOKEN |
โ | โ | Session token for temporary credentials |
The library uses boto3's standard credential chain. Credentials can also come from IAM roles, instance profiles, SSO, or environment variables.
๐งช Testing
# Run all tests
task test
# Run tests with coverage report
task test-cov
# Run mutation testing
task mutation-test
# Run coverage with 100% enforcement
task coverage
# Lint and format
task lint
# Type checking
task typecheck
# Full pre-release check (lint + test + coverage + typecheck)
task prepare
Test Stats
| Metric | Value |
|---|---|
| Test files | 276 |
| Coverage target | 100% |
| Async test support | asyncio_mode = "auto" |
| Mocking framework | moto (S3, SQS, SNS, DynamoDB, Lambda, and more) |
๐ CI/CD
This project uses 20 GitHub Actions workflows for comprehensive automation.
| Workflow | Trigger | Purpose |
|---|---|---|
ci.yml |
Push / PR | Full lint + test + typecheck pipeline |
test.yml |
Push / PR | Run pytest suite |
coverage.yml |
Push / PR | Enforce 100% code coverage |
mutation.yml |
Push / PR | Mutation testing with pytest-gremlins |
lint.yml |
Push / PR | Ruff linting and formatting |
typecheck.yml |
Push / PR | mypy static type checking |
build.yml |
Push / PR | Build package artifacts |
publish.yml |
Tags / Release | Publish to PyPI |
codeql.yml |
Push / PR / Schedule | CodeQL security analysis |
security-scan.yml |
Push / PR | Security vulnerability scanning |
dependency-review.yml |
PR | Review dependency changes |
version-check.yml |
PR | Verify version bump |
changelog.yml |
PR | Validate changelog entries |
pr-size.yml |
PR | Label PRs by size |
label-pr.yml |
PR | Auto-label PRs by file paths |
release-drafter.yml |
Push to master | Draft release notes |
stale.yml |
Schedule | Close stale issues/PRs |
lock-threads.yml |
Schedule | Lock old threads |
issue-triage.yml |
Issues | Auto-triage new issues |
welcome.yml |
PR / Issue | Welcome new contributors |
Pipeline Flow
flowchart LR
PR[Pull Request] --> Lint[๐ Lint]
PR --> Type[๐ Typecheck]
Lint --> Test[๐งช Test]
Type --> Test
Test --> Cov[๐ Coverage 100%]
Test --> Mut[๐งฌ Mutation]
Cov --> |merge to master| Build[๐ฆ Build]
Build --> |tag v*| Publish[๐ PyPI]
All checks must pass before merging. See
.github/workflows/for full configuration.
๐ Changelog
| Version | Date | Highlights |
|---|---|---|
| v2.2.7 | 2026-04-09 | Scoped CI to S3 module for faster test runs |
| v2.2.6 | 2026-04-08 | 6,189 new boto3 method wrappers (7,303 total), 7,682 new tests |
| v2.2.5 | 2026-04-07 | 71 new service modules (135 total), covering 100+ AWS services |
| v2.0.0 | 2026-03-31 | Structured exceptions, native async engine, 64 modules, TTL client cache |
See CHANGELOG.md for the full history.
๐ค Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feat/amazing-feature - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feat/amazing-feature - Open a Pull Request
Development Setup
git clone https://github.com/Masrik-Dahir/aws-util-python.git
cd aws-util-python
pip install -e .[dev]
task prepare # lint + test + coverage + typecheck
Commit Convention
This project uses Conventional Commits:
| Prefix | Use for |
|---|---|
feat: |
New features |
fix: |
Bug fixes |
docs: |
Documentation only |
chore: |
Build / tooling changes |
test: |
Adding or fixing tests |
Please ensure all tests pass and coverage stays at 100% before opening a PR.
๐ License
Distributed under the MIT License. See LICENSE for more information.
Made with โค๏ธ by Masrik Dahir
โญ Star this repo if you find it helpful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws_util-2.2.9.tar.gz.
File metadata
- Download URL: aws_util-2.2.9.tar.gz
- Upload date:
- Size: 4.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1071a8462031d5cf4459f73510291753507a7924d7a594e3a904058fc3218aa8
|
|
| MD5 |
9c5699e78ce1d27bfc3d1d6acfd20d3f
|
|
| BLAKE2b-256 |
b6e99f0daee6eaf4afbfbf84f04252a8ee86369477ac6701f1ea930663e4b1f0
|
Provenance
The following attestation bundles were made for aws_util-2.2.9.tar.gz:
Publisher:
publish.yml on Masrik-Dahir/aws-util-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aws_util-2.2.9.tar.gz -
Subject digest:
1071a8462031d5cf4459f73510291753507a7924d7a594e3a904058fc3218aa8 - Sigstore transparency entry: 1270792826
- Sigstore integration time:
-
Permalink:
Masrik-Dahir/aws-util-python@fce00d96bb9bd3f79cfaba9dfafa77ebcfa1d72c -
Branch / Tag:
refs/tags/v2.2.9 - Owner: https://github.com/Masrik-Dahir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce00d96bb9bd3f79cfaba9dfafa77ebcfa1d72c -
Trigger Event:
release
-
Statement type:
File details
Details for the file aws_util-2.2.9-py3-none-any.whl.
File metadata
- Download URL: aws_util-2.2.9-py3-none-any.whl
- Upload date:
- Size: 2.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad3553279fe60cdf25c1676a2193c1054bc4ddecc73fcc32d22245127a0cb31
|
|
| MD5 |
5c747750f4b02935bf3e55f1d75d7236
|
|
| BLAKE2b-256 |
190c68a57ea53d01fcb183b03d8bb781a8f7f246a602108380756a481e91e8a0
|
Provenance
The following attestation bundles were made for aws_util-2.2.9-py3-none-any.whl:
Publisher:
publish.yml on Masrik-Dahir/aws-util-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aws_util-2.2.9-py3-none-any.whl -
Subject digest:
5ad3553279fe60cdf25c1676a2193c1054bc4ddecc73fcc32d22245127a0cb31 - Sigstore transparency entry: 1270792835
- Sigstore integration time:
-
Permalink:
Masrik-Dahir/aws-util-python@fce00d96bb9bd3f79cfaba9dfafa77ebcfa1d72c -
Branch / Tag:
refs/tags/v2.2.9 - Owner: https://github.com/Masrik-Dahir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce00d96bb9bd3f79cfaba9dfafa77ebcfa1d72c -
Trigger Event:
release
-
Statement type: