This commit is contained in:
2025-11-11 17:06:25 -03:00
parent c00a42ea39
commit 39aedac972
30 changed files with 802 additions and 220 deletions

View File

@@ -10,7 +10,7 @@ from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from boto3clients import dynamodb_client
from config import API_URL, COURSE_TABLE
course_layer = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
dyn = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
@event_source(data_class=DynamoDBStreamEvent)
@@ -21,7 +21,7 @@ def lambda_handler(event: DynamoDBStreamEvent, context: LambdaContext) -> bool:
data = r.json()
now_ = now()
with course_layer.transact_writer() as transact:
with dyn.transact_writer() as transact:
for course in data:
transact.update(
key=KeyPair(course['id'], '0'),

View File

@@ -14,7 +14,7 @@ Globals:
Architectures:
- x86_64
Layers:
- !Sub arn:aws:lambda:sa-east-1:336641857101:layer:layercake:83
- !Sub arn:aws:lambda:sa-east-1:336641857101:layer:layercake:100
Environment:
Variables:
TZ: America/Sao_Paulo
@@ -28,19 +28,19 @@ Resources:
EventLog:
Type: AWS::Logs::LogGroup
Properties:
RetentionInDays: 90
RetentionInDays: 7
EventDailySyncCourseMetadataFunction:
EventCopyCourseMetadataScheduledFunction:
Type: AWS::Serverless::Function
Properties:
Handler: events.daily_sync_course_metadata.lambda_handler
Handler: events.copy_course_metadata.lambda_handler
LoggingConfig:
LogGroup: !Ref EventLog
Policies:
- DynamoDBWritePolicy:
TableName: !Ref CourseTable
Events:
Rule:
ScheduleEvent:
Type: ScheduleV2
Properties:
ScheduleExpression: cron(0 0 * * ? *)

View File

@@ -3,7 +3,7 @@ from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
def test_daily_sync_course_metadata(
def test_copy_course_metadata(
dynamodb_client,
dynamodb_seeds,
dynamodb_persistence_layer: DynamoDBPersistenceLayer,