Skip to content

Instantly share code, notes, and snippets.

@jsonw23
Created June 23, 2020 16:40
Show Gist options
  • Save jsonw23/ab31a283f39956545691b0ca06e1565c to your computer and use it in GitHub Desktop.
Save jsonw23/ab31a283f39956545691b0ca06e1565c to your computer and use it in GitHub Desktop.
import os
import json
import boto3
def lambda_handler(event, context):
# environment variables are native, so use a language-specific
# method to access them, not the lambda context
table = os.environ['TABLE_NAME']
# use the AWS SDK to scan the table by name
client = boto3.client('dynamodb')
response = client.scan(TableName=table)
# dump the scan response into the http response
return {
"statusCode": 200,
"body": json.dumps(response),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment