-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathinsertEmployeeData.py
28 lines (26 loc) · 971 Bytes
/
insertEmployeeData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import boto3
# create a DynamoDB object using the AWS SDK
dynamodb = boto3.resource('dynamodb')
# use the DynamoDB object to select our table
table = dynamodb.Table('employeeProfile')
# define the handler function that the Lambda service will use as an entry point
def lambda_handler(event, context):
# extract values from the event object we got from the Lambda service and store in a variable
firstname = event['empFirstName']
id=event['empId']
lastname=event['empLastName']
age=event['empAge']
# write name and time to the DynamoDB table using the object we instantiated and save response in a variable
response = table.put_item(
Item={
'empId': id,
'empAge':age,
'empFirstName':firstname,
'empLastName':lastname
})
# return a properly formatted JSON object
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda, ' + firstname)
}