update email events

This commit is contained in:
2025-08-21 22:18:51 -03:00
parent 3ab20c485b
commit 45f444a222
7 changed files with 290 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.data_classes import (
EventBridgeEvent,
event_source,
)
from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey
from boto3clients import dynamodb_client
from config import (
ENROLLMENT_TABLE,
)
logger = Logger(__name__)
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@event_source(data_class=EventBridgeEvent)
@logger.inject_lambda_context
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
new_image = event.detail['new_image']
subscription = enrollment_layer.collection.get_items(
TransactKey(new_image['id'])
+ SortKey('METADATA#SUBSCRIPTION_COVERED')
+ SortKey('author')
+ SortKey('tenant')
# Post-migration: uncommet the following lines
# + SortKey('CREATED_BY')
# + SortKey('ORG')
)
with enrollment_layer.transact_writer() as transact_writer:
...
return True