update issue cert

This commit is contained in:
2025-08-29 13:03:57 -03:00
parent a98af3dca5
commit 50ce152880
3 changed files with 16 additions and 33 deletions

View File

@@ -4,7 +4,7 @@ from aws_lambda_powertools.utilities.data_classes import (
event_source, event_source,
) )
from aws_lambda_powertools.utilities.typing import LambdaContext from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from boto3clients import dynamodb_client from boto3clients import dynamodb_client
from config import ( from config import (
@@ -19,10 +19,11 @@ enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@logger.inject_lambda_context @logger.inject_lambda_context
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool: def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
new_image = event.detail['new_image'] new_image = event.detail['new_image']
enrollment = enrollment_layer.collection.get_items( course_metadata = enrollment_layer.collection.get_item(
TransactKey(pk=new_image['id']) KeyPair(
+ SortKey('METADATA#DEDUPLICATION_WINDOW', rename_key='deduplication_window') pk=new_image['id'],
+ SortKey('METADATA#COURSE', rename_key='course'), sk='METADATA#COURSE',
),
) )
return True return True

View File

@@ -45,7 +45,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'email': user['email'], 'email': user['email'],
'course': course_name, 'course': course_name,
'created_at': now_, 'created_at': now_,
'ttl': ttl(days=3, start_dt=now_), 'ttl': ttl(start_dt=now_, days=3),
}, },
) )
@@ -63,7 +63,6 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'ttl': ttl(start_dt=now_, days=access_period), 'ttl': ttl(start_dt=now_, days=access_period),
}, },
) )
print(access_period)
transact.put( transact.put(
item={ item={
'id': enrollment_id, 'id': enrollment_id,

View File

@@ -230,12 +230,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#REMINDER_NO_ACCESS_AFTER_3_DAYS]
- SCHEDULE#REMINDER_NO_ACCESS_AFTER_3_DAYS
# Post-migration: remove the following lines
- schedules#does_not_access
- schedules#reminder_no_access_3_days
- SCHEDULES#REMINDER_NO_ACCESS_AFTER_3_DAYS
# 7 days after the user's last activity in the course # 7 days after the user's last activity in the course
EventReminderNoActivityAfter7DaysFunction: EventReminderNoActivityAfter7DaysFunction:
@@ -257,10 +252,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#REMINDER_NO_ACTIVITY_AFTER_7_DAYS]
- SCHEDULE#REMINDER_NO_ACTIVITY_AFTER_7_DAYS
# Post-migration: remove the following line
- schedules#no_activity
# 30 days before the course access period ends. # 30 days before the course access period ends.
EventReminderAccessPeriodBefore30DaysFunction: EventReminderAccessPeriodBefore30DaysFunction:
@@ -282,10 +274,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#REMINDER_ACCESS_PERIOD_BEFORE_30_DAYS]
- SCHEDULE#REMINDER_ACCESS_PERIOD_BEFORE_30_DAYS
# Post-migration: remove the following line
- schedules#access_period_ends
# If a certificate exists, remind the user 30 days before the certificate expires # If a certificate exists, remind the user 30 days before the certificate expires
EventReminderCertExpirationBefore30DaysFunction: EventReminderCertExpirationBefore30DaysFunction:
@@ -307,10 +296,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS]
- SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS
# Post-migration: remove the following line
- schedules#expiration
# If there is no certificate and the access period has ended, # If there is no certificate and the access period has ended,
# the enrollment will be marked as expired # the enrollment will be marked as expired
@@ -332,10 +318,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#SET_AS_EXPIRED]
- SCHEDULE#SET_AS_EXPIRED
# Post-migration: remove the following line
- schedules#access_period_ends
# After the certificate expires, the enrollment will be marked as archived # After the certificate expires, the enrollment will be marked as archived
EventSetAsArchivedFunction: EventSetAsArchivedFunction:
@@ -356,10 +339,7 @@ Resources:
detail-type: [EXPIRE] detail-type: [EXPIRE]
detail: detail:
keys: keys:
sk: sk: [SCHEDULE#SET_AS_ARCHIVED]
- SCHEDULE#SET_AS_ARCHIVED
# Post-migration: remove the following line
- schedules#archive_it
EventScheduleRemindersFunction: EventScheduleRemindersFunction:
Type: AWS::Serverless::Function Type: AWS::Serverless::Function
@@ -388,6 +368,9 @@ Resources:
Handler: events.issue_cert.lambda_handler Handler: events.issue_cert.lambda_handler
LoggingConfig: LoggingConfig:
LogGroup: !Ref EventLog LogGroup: !Ref EventLog
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref EnrollmentTable
Events: Events:
DynamoDBEvent: DynamoDBEvent:
Type: EventBridgeRule Type: EventBridgeRule