update meilis
This commit is contained in:
@@ -32,7 +32,7 @@ def lambda_handler(event: SESEvent, context: LambdaContext) -> dict:
|
||||
|
||||
print(
|
||||
{
|
||||
'id': f'mailbox#{org_id}',
|
||||
'id': f'mailbox#org#{org_id}',
|
||||
'sk': ses.mail.message_id,
|
||||
}
|
||||
)
|
||||
|
||||
4
users-events/app/events/stopgap/__init__.py
Normal file
4
users-events/app/events/stopgap/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
"""
|
||||
Stopgap events. Everything here is a quick fix and should be replaced with
|
||||
proper solutions.
|
||||
"""
|
||||
30
users-events/app/events/stopgap/add_tenant.py
Normal file
30
users-events/app/events/stopgap/add_tenant.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from aws_lambda_powertools.utilities.data_classes import (
|
||||
EventBridgeEvent,
|
||||
event_source,
|
||||
)
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import USER_TABLE
|
||||
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
@event_source(data_class=EventBridgeEvent)
|
||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
new_image = event.detail['new_image']
|
||||
now_ = now()
|
||||
_, tenant = new_image['id'].split('#')
|
||||
|
||||
user_layer.update_item(
|
||||
key=KeyPair(new_image['sk'], '0'),
|
||||
update_expr='ADD tenant :tenant SET updated_at = :updated_at',
|
||||
expr_attr_values={
|
||||
':tenant': {tenant},
|
||||
':updated_at': now_,
|
||||
},
|
||||
)
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user