Skip to content

Instantly share code, notes, and snippets.

@behconsci
Created December 24, 2017 09:34
Show Gist options
  • Save behconsci/825a34971f20e2b350e39fcca8b85fbe to your computer and use it in GitHub Desktop.
Save behconsci/825a34971f20e2b350e39fcca8b85fbe to your computer and use it in GitHub Desktop.
AWS Class with aws services
class AWS(object):
def __init__(self):
self.aws_session = boto3.Session(
aws_access_key_id=settings.AWS_ACCESS_KEY,
aws_secret_access_key=settings.AWS_SECRET_KEY,
region_name='eu-central-1'
) # todo: offload these credentials to external locations e.g. OS Keychain
def dynamo_db_table(self, table_name=None):
if table_name:
db = self.aws_session.resource('dynamodb')
return db.Table(table_name)
warnings.warn('Please give table_name', UserWarning)
def iot(self):
return self.aws_session.resource('iot')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment