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

Globals:
  Function:
    CodeUri: .
    Runtime: python3.13
    Architectures:
      - x86_64
    Layers:
      - !Sub arn:aws:lambda:sa-east-1:336641857101:layer:layercake:35
    Environment:
      Variables:
        LOG_LEVEL: DEBUG
        TZ: America/Sao_Paulo
        POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1
        POWERTOOLS_LOGGER_LOG_EVENT: true
        MEILISEARCH_HOST: https://meili.vps.eduseg.com.br
        MEILISEARCH_API_KEY: "{{resolve:ssm:/saladeaula/meili_api_key}}"

Resources:
  MeilisearchLog:
    Type: AWS::Logs::LogGroup
    Properties:
      RetentionInDays: 90

  EventIndexDocsFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: events.index_docs.lambda_handler
      LoggingConfig:
        LogGroup: !Ref MeilisearchLog
      Events:
        Users:
          Type: DynamoDB
          Properties:
            Stream: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/betaeducacao-prod-users_d2o3r5gmm4it7j/stream/2022-06-12T21:33:25.634
            StartingPosition: LATEST
            MaximumRetryAttempts: 5
            BatchSize: 25
            FilterCriteria:
              Filters:
                - Pattern: '{ "dynamodb" : { "Keys" : { "sk" : { "S" : [ "0" ] } } } }'

        Enrollments:
          Type: DynamoDB
          Properties:
            Stream: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/betaeducacao-prod-enrollments/stream/2023-08-22T22:56:55.612
            StartingPosition: LATEST
            MaximumRetryAttempts: 5
            BatchSize: 25
            FilterCriteria:
              Filters:
                - Pattern: '{ "dynamodb" : { "Keys" : { "sk" : { "S" : [ "0" ] } } } }'

        Orders:
          Type: DynamoDB
          Properties:
            Stream: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/betaeducacao-prod-orders/stream/2023-09-15T18:58:50.395
            StartingPosition: LATEST
            MaximumRetryAttempts: 5
            BatchSize: 25
            FilterCriteria:
              Filters:
                - Pattern: '{ "dynamodb" : { "Keys" : { "sk" : { "S" : [ "0" ] } } } }'

        Courses:
          Type: DynamoDB
          Properties:
            Stream: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/saladeaula_courses/stream/2025-03-12T20:42:46.706
            StartingPosition: LATEST
            MaximumRetryAttempts: 5
            BatchSize: 25
            FilterCriteria:
              Filters:
                - Pattern: '{ "dynamodb" : { "Keys" : { "sk" : { "S" : [ "0" ] } } } }'
