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.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62a950fa5524913f1a0449d79595c397318f3c6baf96f0383e2a1a08775c6c82 |
|
MD5 | 17d0bfa1822d9ea69b2062e966c214c9 |
|
BLAKE2b-256 | 0c8760c6877b850a6c49b251fc783d955008fef5c3df8391bf1485be33863c04 |
Close
Hashes for aws_hexagonal_adapters-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f3a926f5292c3dc56feeee46539e725793be4653060dba96a13579ec19a0db3 |
|
MD5 | cbce95a7a0d0f843b3663acbc9ca51ba |
|
BLAKE2b-256 | deaf8d08a90ff1051a4862b0475718a5107597c825ca413e06a815b63e50d390 |