GithubHelp home page GithubHelp logo

mbenencase / py-aws Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

A simple package with tools to easy upload, download files from S3. Read/Write to SQS. Read/Write from Dynamo tables.

License: MIT License

Python 99.50% Shell 0.50%

py-aws's Introduction

AWS SDK

A simple tool to perform daily tasks.

IMPORTANT

This library assumes that you have your credentials already set at $HOME/.aws. Install AWS CLI and configure your machine before moving on.

If you want to use this library in a Docker image, I suggest to use: -v $HOME/.aws:/root/.aws.

How to Install

pip3 install aws-easy-tool

Usage

DynamoDB

Currently, we only support send an item to DynamoDB:

import uuid
import pyaws
import time

class MyDynamoItem(pyaws.DynamoItem):
    username: str
    password: str
    email: str
    uuid: str
    timestamp: int

my_item = MyDynamoItem(
    username="johndoe",
    password="123456",
    email="[email protected]",
    uuid=str(uuid.uuid4()),
    timestamp=int(time.time() \* 1000)
)

dynamo_client = pyaws.DynamoDB.get_dynamodb_client()
response = pyaws.DynamoDB.put_item(dynamo_client, table_name="users", item=my_item)

# You can check, later, the HTTP response inside the `response` variable.

Simple Storage Service (S3)

To get or put a file to S3, we assume that you'll upload a local file stored in your computer/server.

import pyaws

s3_client = pyaws.S3.get_s3_client()

response = pyaws.S3.put_item_from_local_path(
    s3_client=s3_client,
    bucket_name="my-website",
    file_pth="/tmp/index.html",
    s3_pth="index.html" # -> It will store in the root of the bucket.
)

# You can check, later, the HTTP response inside the `response` variable.

Simple Queue Service (SQS)

We assume that you have set your Queue as a First-In-First-Out (FIFO) queue in your AWS console.


import pyaws

sqs_client = pyaws.SQS.get_sqs_client()

# This is a simple template to follow to send your messages through the SQS queue.
# it has already a message uuid in case you want it.
message = pyaws.SQSMessage(
    body={
        "message": "Hello World
    }
)

response = pyaws.SQS.add_message_to_queue(
    sqs_client=sqs_client,
    output_queue_url="your-sqs-queue-url",
    message=message,
    message_group_id="my-message-group-id"
)

py-aws's People

Contributors

mbenencase avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.