AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::Serverless-2016-10-31 Parameters: UserTable: Type: String Default: betaeducacao-prod-users_d2o3r5gmm4it7j EnrollmentTable: Type: String Default: betaeducacao-prod-enrollments OrderTable: Type: String Default: betaeducacao-prod-orders CourseTable: Type: String Default: saladeaula_courses Globals: Function: CodeUri: app/ Runtime: python3.13 Tracing: Active Architectures: - x86_64 Layers: - !Sub arn:aws:lambda:sa-east-1:336641857101:layer:layercake:83 Environment: Variables: TZ: America/Sao_Paulo LOG_LEVEL: DEBUG DYNAMODB_PARTITION_KEY: id POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1 POWERTOOLS_LOGGER_LOG_EVENT: true USER_TABLE: !Ref UserTable ORDER_TABLE: !Ref OrderTable ENROLLMENT_TABLE: !Ref EnrollmentTable COURSE_TABLE: !Ref CourseTable Resources: EventLog: Type: AWS::Logs::LogGroup Properties: RetentionInDays: 90 EventBillingAddEnrollmentFunction: Type: AWS::Serverless::Function Properties: Handler: events.billing.add_enrollment.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBCrudPolicy: TableName: !Ref OrderTable - DynamoDBReadPolicy: TableName: !Ref EnrollmentTable - DynamoDBReadPolicy: TableName: !Ref CourseTable Events: Event: Type: EventBridgeRule Properties: Pattern: resources: [!Ref EnrollmentTable] detail-type: [INSERT] detail: new_image: sk: ["METADATA#BILLING_TERMS"] EventAppendOrgIdFunction: Type: AWS::Serverless::Function Properties: Handler: events.append_org_id.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBCrudPolicy: TableName: !Ref UserTable - DynamoDBCrudPolicy: TableName: !Ref OrderTable Events: Event: Type: EventBridgeRule Properties: Pattern: resources: [!Ref OrderTable] detail-type: [INSERT] detail: new_image: sk: ["0"] cnpj: - exists: true # Post-migration: rename `tenant_id` to `org_id` tenant_id: - exists: false EventAppendUserIdFunction: Type: AWS::Serverless::Function Properties: Handler: events.append_user_id.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBCrudPolicy: TableName: !Ref UserTable - DynamoDBCrudPolicy: TableName: !Ref OrderTable Events: Event: Type: EventBridgeRule Properties: Pattern: resources: [!Ref OrderTable] detail-type: [INSERT] detail: new_image: sk: ["0"] cpf: - exists: true user_id: - exists: false EventRemoveSlotsIfCanceledFunction: Type: AWS::Serverless::Function Properties: Handler: events.remove_slots_if_canceled.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBWritePolicy: TableName: !Ref OrderTable - DynamoDBWritePolicy: TableName: !Ref EnrollmentTable Events: Event: Type: EventBridgeRule Properties: Pattern: resources: [!Ref OrderTable] detail-type: [MODIFY] detail: new_image: sk: ["0"] cnpj: - exists: true status: [CANCELED, EXPIRED] EventStopgapSetAsPaidFunction: Type: AWS::Serverless::Function Properties: Handler: events.stopgap.set_as_paid.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBWritePolicy: TableName: !Ref OrderTable Events: Event: Type: EventBridgeRule Properties: Pattern: resources: [!Ref OrderTable] detail-type: [INSERT] detail: new_image: sk: ["0"] cnpj: - exists: true total: [0] status: [CREATING, PENDING] payment_method: [MANUAL] EventStopgapRemoveSlotsFunction: Type: AWS::Serverless::Function Properties: Handler: events.stopgap.remove_slots.lambda_handler LoggingConfig: LogGroup: !Ref EventLog Policies: - DynamoDBReadPolicy: TableName: !Ref UserTable - DynamoDBReadPolicy: TableName: !Ref OrderTable - DynamoDBCrudPolicy: TableName: !Ref EnrollmentTable Events: DynamoDBEvent: Type: EventBridgeRule Properties: Pattern: resources: [!Ref OrderTable] detail: new_image: sk: [generated_items] status: [SUCCESS]