AWS Utils 🚀
A Python library to simplify interaction with AWS services such as SES (Simple Email Service), SSM (Systems Manager Parameter Store), and CloudWatch Logs.
Designed and maintained by Luigi Moro
Features ✨
- SES Email Client: Send emails (with or without attachments) via AWS SES.
- SSM Parameter Manager: Retrieve and manage parameters from AWS Systems Manager Parameter Store.
- CloudWatch Logs Collector: Query and process logs from AWS CloudWatch.
- Type hints and modern Python practices for robust, maintainable code.
- Easily testable with pytest and mocks.
Installation ⚡
pip install -r requirements.txt
Or, if using poetry:
poetry install
Usage 📚
SES Email Client ✉️
Send emails with or without attachments via AWS SES.
from aws_utils.ses.email_manager import SesEmailClient
email_client = SesEmailClient(
region_name="eu-west-1",
aws_access_key_id="YOUR_AWS_ACCESS_KEY_ID",
aws_secret_access_key="YOUR_AWS_SECRET_ACCESS_KEY",
aws_session_token="YOUR_AWS_SESSION_TOKEN"
)
# Send email with attachment
email_client.send_email(
source="sender@example.com",
to_addresses=["recipient@example.com"],
subject="Test Email with Attachment",
body="This is a test email with an attachment.",
attachments=["/path/to/file.txt"]
)
SSM Parameter Manager 🗝️
Retrieve parameters from AWS SSM:
from aws_utils.ssm.parameters_manager import PropertiesManager
manager = PropertiesManager()
value = manager.fetch_parameter_value('parameter_key')
print(value)
CloudWatch Logs Collector 📈
Query CloudWatch logs:
from aws_utils.cloudwatch.log_utils import CloudWatchLogsCollector
collector = CloudWatchLogsCollector(log_group="your-log-group")
logs = collector.collect_raw_logs(
query="fields @timestamp, @message | sort @timestamp desc",
start=datetime(2024, 1, 1),
end=datetime(2024, 1, 2)
)
print(logs)
Testing 🧪
Tests are written with pytest and use mocks for AWS clients.
pytest
Example test for SES email sending (see tests/aws_utils/ses/test_email_manager.py):
from unittest.mock import patch, MagicMock
from aws_utils.ses.email_manager import SesEmailClient
def test_send_email_without_attachment():
with patch("boto3.client") as mock_boto_client:
mock_ses = MagicMock()
mock_boto_client.return_value = mock_ses
client = SesEmailClient("eu-west-1", "key", "secret", "token")
mock_ses.send_email.return_value = {"MessageId": "123"}
result = client.send_email(
source="from@example.com",
to_addresses=["to@example.com"],
subject="Subject",
body="Body"
)
assert result == {"MessageId": "123"}
Documentation 📖
- Project documentation: GitHub Pages
- For access issues, contact:
luigi.moro.1976@gmail.com
Contributing 🤝
- Fork the repo and create your branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Open a pull request
License 📄
Metadata
Release files for aws-services-utils 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aws_services_utils-0.0.6.tar.gz | 8.2 kB | Without provenance | Details for aws_services_utils-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aws_services_utils-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for aws_services_utils-0.0.6-py3-none-any.whl |
Total release size: 18.0 kB
Release files / aws_services_utils-0.0.6.tar.gz
| Download URL | aws_services_utils-0.0.6.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45cb2a4df28c3dcc894d2cfb927906b9e67ebfb2452e5aa39a6185bcf29234dd
|
|
BLAKE2b-256 checksum How to use checksums |
4c8dd4e3be89d8dd8b1cefbfb235182fcfa388ec73e069e103881c7ae94aec83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.11
|
Release files / aws_services_utils-0.0.6-py3-none-any.whl
| Download URL | aws_services_utils-0.0.6-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0823c2ccfcf489e3886eec201d190df46aa5d636ebb330a0982c5ac06c9c2fde
|
|
BLAKE2b-256 checksum How to use checksums |
0ef2f2a00d4a802d19206065040ff8023593b0933349d18b0bc350b4194e2890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.11
|
Security for aws-services-utils 0.0.6
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.