- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_function.py
More file actions
Latest commit
23 lines (17 loc) · 747 Bytes
/
Copy pathlambda_function.py
File metadata and controls
23 lines (17 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
importboto3
importos
fromboto3.dynamodb.conditionsimportKey
DYNAMO_BD=os.environ['DYNAMO_BD']
# Hola a todos estoy con RedHat y los companeritos
# Modificacion ED, Wed Feb 16 00:00:55 -05 2022
classDynamoAccessor:
def__init__(self, dynamo_table):
dynamo_db=boto3.resource('dynamodb')
self.table=dynamo_db.Table(dynamo_table)
defget_data_from_dynamo(self, CC):
response=self.table.query(KeyConditionExpression=Key('CC').eq(CC))
returnresponse["Items"][0] ifany(response["Items"]) elseNone
deflambda_handler(event, context):
dynamo_backend=DynamoAccessor(DYNAMO_BD)
db_element=dynamo_backend.get_data_from_dynamo(event['CC'])
returndb_element