Package: simple-AWS
SimpleAWSVersion 0.1.6Simplified Libraries for some of the most common AWS resources. The purpose of SimpleAWS is to add one layer of abstraction, and remove a lot of the guess-work from interfacing with some AWS resources.The options are limited on purpose - this isnotdesigned to replace boto3, but to provide an easier entry into using AWS resources with python.AWS RequirementsSimpleAWS uses profiles and secret/access keys. Put a file called 'credentials' inside the .aws directory in your home directory (the home of the user running this code.) The format of the file is:[profilename]
aws_access_key_id = <key>
aws_secret_access_key = <key>Installationpip install simple-awsUsagefrom simple_AWS.aws_functions import *
from simple_AWS.dynamodb_functions import *
from simple_AWS.s3_functions import *
from simple_AWS.sns_functions import *
from simple_AWS.sqs_functions import *OverallGet Regions for a serviceregions = aws.list_regions(service=service)S3List bucketss3simple = S3Simple(region_name='region', profile='profile')
bucket_list = s3simple.list_buckets()
# returns a listGet a list of files in a buckets3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
file_list = s3simple.s3_bucket_contents()
# returns a listGet a filtered list of files in a buckets3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
filtered_list = s3simple.s3_bucket_filter(prefix='file_name.ext')
# returns a listDownload a files3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
s3simple.download_file(file_name='file_name.ext', output_file='/path/file_name.txt')Create Buckets3simple = S3Simple(region_name='region', profile='profile', bucket_name='new-bucket-name')
new_bucket = s3simple3.s3_new_bucket()Delete Buckets3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
s3simple.s3_delete_bucket()Saving text to files3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
key = 'test_item.txt'
    body = """
    Hundreds of thousands light years shores of the cosmic ocean circumnavigated white dwarf Rig Veda. 
    Courage of our questions something incredible is waiting to be known extraordinary claims require 
    extraordinary evidence brain is the seed of intelligence laws of physics extraordinary claims require 
    extraordinary evidence. Dream of the mind's eye invent the universe emerged into consciousness made 
    in the interiors of collapsing stars something incredible is waiting to be known finite but unbounded.
    """
s3simple.put_to_s3(key=key, body=body)Sending file to S3s3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
s3simple.send_file_to_s3(local_file='/path/file_name.ext', s3_file='file_name.ext')To make that file publically available (not recommended!):s3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
s3simple.send_file_to_s3(local_file='/path/file_name.ext', s3_file='file_name.ext', public=True)Delete Files3simple = S3Simple(region_name='region', profile='profile', bucket_name='bucket-name')
s3simple.delete_s3_file(file_name=key)DynamoDBChecking to see if a table existsdbsimple = DynamodbSimple(table_name='table_name', region_name='region', profile='profile') 
# region and profile are optional
if dbsimple.check_table(): # returns True/False
    ...List all Tablesdbsimple = DynamodbSimple(table_name=test_new_table, region_name=test_region, profile=test_profile)
table_list = dbsimple.list_tables()
# returns a listCreating a Tabledbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
dbsimple.create_table(
    partition_key='foo',
    sort_key='bar', #optional
    throughput='5'
)Delete a tabledbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
dbsimple.delete_table()Writing data in bulkdbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
dbsimple.batch_write_items(items=items) # items is a list of dictsWriting individual itemsdbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
for item in items:
    dbsimple.insert_item(item=item) #item is a dictDynamo Querydbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
data = dbsimple.dynamo_query(
    field='foo', # field must be partition key, sort key or indexed
    value='baseball'
    )
# returns a list of dictsDynamo Scandbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
data = dbsimple.dynamo_scan(
    key='moo', # any key
    value='mar'
)
# returns a list of dictsGet all datadbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
all_data = dbsimple.get_all() # returns a list of dictsDelete key/value pairdbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
dbsimple.delete_item(
    key='foo', # key must be partition key, sort key or indexed
    value='giraffe'
)Update DynamoDB entrydbsimple = DynamodbSimple(region_name='region', profile='profile', table_name='table_name')
dbsimple.update_item(
    key='woo',
    value='sageing',
    id_key='foo', # key must be partition key, sort key or indexed
    id_value='yar'
)SQSDoes a Queue Exist?sqs_simple = sqsSimple(region_name='region', profile='profile', queue_name='queue_name')
sqs_simple.queue_exists()List Queuessqs_simple = sqsSimple(region_name='region', profile='profile')
sqs_list = sqs_simple.list_queues()
# returns a listCreate Queuesqs_simple = sqsSimple(region_name='region', profile='profile') 
sqs_simple.create_queue(queue='queue_name')Delete Queuesqs_simple = sqsSimple(region_name='region', profile='profile', queue='queue_name')
sqs_simple.delete_queue()Send Messagesqs_simple = sqsSimple(region_name='region', profile='profile', queue='queue_name')
sqs_simple.send_sqs_message(message=message) # message is textGet Messagessqs_simple = sqsSimple(region_name='region', profile='profile', queue='queue_name')
messages = sqs_simple.get_sqs_messages(num_messages=5)
# returns a listPurge Queuesqs_simple = sqsSimple(region_name='region', profile='profile', queue='queue_name')
sqs_simple.purge_queue()SNSList Topicssns_simple = snsSimple(region_name='region', profile='profile')
topics = sns_simple.list_topics()
# Returns a listList Subscriptionssns_simple = snsSimple(region_name='region', profile='profile')
subscriptions = sns_simple.list_subscriptions()
# Returns a listSend Messagesns_simple = snsSimple(region_name='region', profile='profile')
sns_simple.send_notification(arn='AWS Topic ARN', subject='subject', message='message')CloudFrontList Distributionscfsimple = Cloudfront_Simple(region_name=test_region, profile=test_profile)
dists = cfsimple.cf_list()Get Details of a Distributioncfsimple = Cloudfront_Simple(region_name=test_region, profile=test_profile)
details = cfsimple.cf_details(id=cf_id)

or

details = cfsimple.cf_details(domain=domain)
    
or

details3 = cfsimple.cf_details(alias=alias)

or

details4 = cfsimple.cf_details(origin=origin)Create an Invalidationcfsimple = Cloudfront_Simple(region_name=region, profile=profile)
 response = cfsimple.cf_invalidate(cf_id, path)EC2List Instancesec2 = ec2Simple(region_name=region, profile=test_profile)
instances = ec2.list_instances()
# Returns instance iteratorTestsThere is under /tests simple_aws_tests_sample.py, with example code to test each of the services.CLIUnder /cli there are two files: simple_aws_inventory_sample.py, which allows you to run an inventory of all resources under the following services: EC2 instances, S3 buckets, DynamoDB tables, SNS Topics and subscriptions, and SQS Queues under all regions. The other is simple_aws_cf_invalidation.py,which requires the python library 'click', and can create an invalidation by domain name.