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,
)
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 config import (
@@ -19,10 +19,11 @@ enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@logger.inject_lambda_context
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
new_image = event.detail['new_image']
enrollment = enrollment_layer.collection.get_items(
TransactKey(pk=new_image['id'])
+ SortKey('METADATA#DEDUPLICATION_WINDOW', rename_key='deduplication_window')
+ SortKey('METADATA#COURSE', rename_key='course'),
course_metadata = enrollment_layer.collection.get_item(
KeyPair(
pk=new_image['id'],
sk='METADATA#COURSE',
),
)
return True

View File

@@ -45,7 +45,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'email': user['email'],
'course': course_name,
'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),
},
)
print(access_period)
transact.put(
item={
'id': enrollment_id,

View File

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