This commit is contained in:
2025-06-06 18:32:09 -03:00
parent 3e44761e69
commit 53613d0a48
34 changed files with 939 additions and 752 deletions

View File

@@ -7,7 +7,7 @@ def get_dynamodb_client():
if os.getenv('AWS_LAMBDA_FUNCTION_NAME'):
return boto3.client('dynamodb')
return boto3.client('dynamodb', endpoint_url='http://localhost:8000')
return boto3.client('dynamodb', endpoint_url='http://127.0.0.1:8000')
dynamodb_client = get_dynamodb_client()

View File

@@ -3,3 +3,4 @@ import os
USER_TABLE: str = os.getenv('USER_TABLE') # type: ignore
ORDER_TABLE: str = os.getenv('ORDER_TABLE') # type: ignore
ENROLLMENT_TABLE: str = os.getenv('ENROLLMENT_TABLE') # type: ignore
NEW_ENROLLMENT_TABLE: str = os.getenv('NEW_ENROLLMENT_TABLE') # type: ignore

View File

@@ -0,0 +1,4 @@
"""
Stopgap events. Everything here is a quick fix and should be replaced with
proper solutions.
"""

View File

@@ -0,0 +1,14 @@
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
logger = Logger(__name__)
@event_source(data_class=EventBridgeEvent)
@logger.inject_lambda_context
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
return True

View File

@@ -8,6 +8,9 @@ Parameters:
EnrollmentTable:
Type: String
Default: betaeducacao-prod-enrollments
NewEnrollmentTable:
Type: String
Default: saladeaula_enrollments
OrderTable:
Type: String
Default: betaeducacao-prod-orders
@@ -38,10 +41,32 @@ Resources:
Properties:
RetentionInDays: 90
EventDelVacanciesFunction:
EventEnrollFunction:
Type: AWS::Serverless::Function
Properties:
Handler: events.stopgap.del_vacancies.lambda_handler
Handler: events.stopgap.enroll.lambda_handler
LoggingConfig:
LogGroup: !Ref EventLog
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref NewEnrollmentTable
- DynamoDBReadPolicy:
TableName: !Ref EnrollmentTable
Events:
DynamoDBEvent:
Type: EventBridgeRule
Properties:
Pattern:
resources: [!Ref EnrollmentTable]
detail-type: [INSERT]
detail:
new_image:
sk: ["0"]
EventDeleteVacanciesFunction:
Type: AWS::Serverless::Function
Properties:
Handler: events.stopgap.delete_vacancies.lambda_handler
LoggingConfig:
LogGroup: !Ref EventLog
Policies:

View File

@@ -1,6 +1,6 @@
from layercake.dynamodb import PartitionKey
import events.stopgap.del_vacancies as app
import events.stopgap.delete_vacancies as app
from ...conftest import LambdaContext