Adapters following hexagonal architecture to connect various AWS services.
Project description
aws-hexagonal-adapters
Adapters following hexagonal architecture to connect various AWS services
Example usage
S3
Download object
from os import environ
from aws_hexagonal_adapters.s3_service import S3Service
S3_SERVICE = S3Service(region_name=environ["CURRENT_REGION"])
# Download file
S3_SERVICE.download(
bucket="bucket_name", local_path=f"/tmp/object", remote_path="object"
)
Upload object
from os import environ
from aws_hexagonal_adapters.s3_service import S3Service
S3_SERVICE = S3Service(region_name=environ["CURRENT_REGION"])
# Download file
S3_SERVICE.upload(
bucket="bucket_name",
local_path=f"/tmp/object_name",
remote_path="object_name",
extra_args={"StorageClass": "STANDARD_IA"},
)
List objects
from os import environ
from aws_hexagonal_adapters.s3_service import S3Service
S3_SERVICE = S3Service(region_name=environ["CURRENT_REGION"])
# Download file
S3_SERVICE.list_files(bucket="bucket_name", prefix="folder_name")
Delete object
from os import environ
from aws_hexagonal_adapters.s3_service import S3Service
S3_SERVICE = S3Service(region_name=environ["CURRENT_REGION"])
# Download file
S3_SERVICE.delete_object(bucket="bucket_name", key="object_name")
Delete objects
from os import environ
from aws_hexagonal_adapters.s3_service import S3Service
S3_SERVICE = S3Service(region_name=environ["CURRENT_REGION"])
objects = ["folder/object1.txt", "folder/object2.txt", "folder/object3.txt"]
# Download file
S3_SERVICE.delete_objects(bucket="bucket_name", keys=objects)
DynamoDB
Get Item
from os import environ
from aws_hexagonal_adapters.dynamo_db_service import DynamoDBService
DYNAMODB_SERVICE = DynamoDBService(region_name=environ["REGION_NAME"])
item = DYNAMODB_SERVICE.get_item(
table_name=environ["DYNAMODB_TABLE_NAME"],
key={"pk": f'{environ["DYNAMODB_TABLE_ITEM_NAME"]}', "sk": "1"},
)
Get Items
from os import environ
from boto3.dynamodb.conditions import Key
from aws_hexagonal_adapters.dynamo_db_service import DynamoDBService
DYNAMODB_SERVICE = DynamoDBService(region_name=environ["REGION_NAME"])
item = DYNAMODB_SERVICE.get_items(
table_name=environ["DYNAMODB_TABLE_NAME"],
filter_expression=Key("sk").eq("2"),
)
Scan
from os import environ
from aws_hexagonal_adapters.dynamo_db_service import DynamoDBService
DYNAMODB_SERVICE = DynamoDBService(region_name=environ["REGION_NAME"])
item = DYNAMODB_SERVICE.scan_items(
table_name=environ["DYNAMODB_TABLE_NAME"],
index_name=environ["DYNAMODB_INDEX_NAME"],
)
SQS
from os import environ
from aws_hexagonal_adapters.sqs_service import SQSService
SQS_SERVICE = SQSService(region_name=environ["REGION_NAME"])
messages = SQS_SERVICE.receive_messages(queue_url=environ["SQS_QUEUE_NAME"])
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
Close
Hashes for aws_hexagonal_adapters-1.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 140405092ee36c97efa828bef1f2db2a0c90cadbed0482116b32f0f1ada86a89 |
|
MD5 | 74a425bf6604342b9c67137d737aa9ea |
|
BLAKE2b-256 | dd59be0af09758d72edf018b978eb0c5c336a8c0154c555481c9031d5eea829f |
Close
Hashes for aws_hexagonal_adapters-1.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab348172853c2c7a0b87a14923f5b2f0c5691c8a6992645e64a5f43ea7f71246 |
|
MD5 | adbaed4372f5fd500d5e80f31c7682b8 |
|
BLAKE2b-256 | 3795246312cb76add4c2b79e3ee086dcb73ca9cb45b7e9fddce461cf5c65a51b |