fix
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from arnparse import arnparse
|
||||
from aws_lambda_powertools import Logger
|
||||
from aws_lambda_powertools import Logger, Tracer
|
||||
from aws_lambda_powertools.utilities.data_classes import (
|
||||
DynamoDBStreamEvent,
|
||||
event_source,
|
||||
@@ -8,13 +7,16 @@ from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from config import MEILISEARCH_API_KEY, MEILISEARCH_HOST
|
||||
from meili import Op
|
||||
from meilisearch import Client as Meilisearch
|
||||
from utils import table_from_arn
|
||||
|
||||
logger = Logger(__name__)
|
||||
tracer = Tracer()
|
||||
meili_client = Meilisearch(MEILISEARCH_HOST, MEILISEARCH_API_KEY)
|
||||
|
||||
|
||||
@event_source(data_class=DynamoDBStreamEvent)
|
||||
@logger.inject_lambda_context
|
||||
@tracer.capture_lambda_handler
|
||||
def lambda_handler(event: DynamoDBStreamEvent, context: LambdaContext):
|
||||
with Op(meili_client) as op:
|
||||
for record in event.records:
|
||||
@@ -29,12 +31,7 @@ def lambda_handler(event: DynamoDBStreamEvent, context: LambdaContext):
|
||||
)
|
||||
|
||||
|
||||
def table_from_arn(arn: str) -> str:
|
||||
arn_ = arnparse(arn)
|
||||
return arn_.resource.split('/')[0]
|
||||
|
||||
|
||||
# Post-migration: remove the following lines
|
||||
# Post-migration: remove the following function
|
||||
def sanitize(obj):
|
||||
if isinstance(obj, dict):
|
||||
return {k.replace(':', '__'): sanitize(v) for k, v in obj.items()}
|
||||
|
||||
Reference in New Issue
Block a user