import boto3
import json
import time
def lambda_handler(event, context):
# TODO implement
add = boto3.client('dynamodb')
for record in event["Records"]:
BucketName = record["s3"]["bucket"]["name"]
BucketArn = record["s3"]["bucket"]["arn"]
ObjectName = record["s3"]["object"]["key"]
ObjectSize = str(record["s3"]["object"]["size"])
item = {
"username":{"S":ObjectName},
"age":{"N":ObjectSize},
"ttt":{"S":BucketName},
"yhww":{"S":BucketArn}
}
tableName = "yhw"
add.put_item(TableName = tableName, Item = item)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}