update email events
This commit is contained in:
35
enrollments-events/app/events/reenroll_if_failed.py
Normal file
35
enrollments-events/app/events/reenroll_if_failed.py
Normal 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
|
||||
Reference in New Issue
Block a user