Skip to content

Instantly share code, notes, and snippets.

@shar1z
Created August 1, 2022 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shar1z/ecfa6348031db72f4635bbe1555917ea to your computer and use it in GitHub Desktop.
Save shar1z/ecfa6348031db72f4635bbe1555917ea to your computer and use it in GitHub Desktop.
"""
data_layer.py - how to use the credentials
"""
from decorators import get_dynamodb_session_keys
def some_data_access_method():
session = boto3.Session(**get_dynamodb_session_keys())
dynamodb = session.resource("dynamodb")
table = dynamodb.Table(TABLE_NAME)
# now we can use 'table' to access with tenant_id restrictions
And then hooking it all together into our handler file:
"""
handler.py - applying to our lambda
"""
from decorators import dynamodb_tenant_isolation
@dynamodb_tenant_isolation
def handler(event, context):
# our lambda code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment