AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Parameters:
  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:100
    Environment:
      Variables:
        TZ: America/Sao_Paulo
        LOG_LEVEL: DEBUG
        POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1
        POWERTOOLS_LOGGER_LOG_EVENT: true
        DYNAMODB_PARTITION_KEY: id
        COURSE_TABLE: !Ref CourseTable

Resources:
  EventLog:
    Type: AWS::Logs::LogGroup
    Properties:
      RetentionInDays: 7

  EventCopyCourseMetadataScheduledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: events.copy_course_metadata.lambda_handler
      LoggingConfig:
        LogGroup: !Ref EventLog
      Policies:
        - DynamoDBWritePolicy:
            TableName: !Ref CourseTable
      Events:
        ScheduleEvent:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: cron(0 0 * * ? *)
            ScheduleExpressionTimezone: America/Sao_Paulo
