Skip to content

Commit d94b932

Browse files
committed
Added layer and function code
1 parent 5f2a7c2 commit d94b932

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

boto3-layer.zip

8.02 MB
Binary file not shown.

json_to_dynamodb_function.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
import boto3
3+
import os
4+
import urllib.parse
5+
import json
6+
import uuid
7+
from decimal import Decimal
8+
s3_client = boto3.client('s3')
9+
dynamodb = boto3.resource('dynamodb')
10+
def lambda_handler(event, context):
11+
print("Starting Transfer:")
12+
bucket = event['Records'][0]['s3']['bucket']['name']
13+
json_file_name = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8')
14+
json_object = s3_client.get_object(Bucket = bucket, Key = json_file_name)
15+
jsonFileReader = json_object['Body'].read()
16+
jsonDict = json.loads(jsonFileReader, parse_float=Decimal)
17+
table = dynamodb.Table('s3-json-textract-table')
18+
finalObject = jsonDict[0]
19+
finalObject["key"] = json_file_name
20+
finalObject['id'] = str(uuid.uuid4())
21+
table.put_item(Item = jsonDict[0])
File renamed without changes.

s3_to_pdf_trust_relationship.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Version": "2012–10–17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Principal": {
7+
"Service": "lambda.amazonaws.com"
8+
},
9+
"Action": "sts:AssumeRole"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)