aws-lambda-log-proxy 0.4.0

Filter or transform logs from AWS Lambda functions before they are sent to CloudWatch Logs.
Documentation
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Globals:
  Function:
    Handler: src/index.handler
    Runtime: nodejs20.x
    CodeUri: nodejs
    MemorySize: 1024
    Timeout: 30

Resources:
  LambdaLogProxyLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      ContentUri: layer/
      CompatibleArchitectures:
        - x86_64
  LambdaLogProxy10EnabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - !Ref LambdaLogProxyLayer
      Environment:
        Variables:
          AWS_LAMBDA_EXEC_WRAPPER: /opt/entry.sh
          LOG_COUNT: "10"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /10/enabled
            Method: get
  LambdaLogProxy10DisabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          LOG_COUNT: "10"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /10/disabled
            Method: get
  LambdaLogProxy100EnabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - !Ref LambdaLogProxyLayer
      Environment:
        Variables:
          AWS_LAMBDA_EXEC_WRAPPER: /opt/entry.sh
          LOG_COUNT: "100"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /100/enabled
            Method: get
  LambdaLogProxy100DisabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          LOG_COUNT: "100"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /100/disabled
            Method: get
  LambdaLogProxy1000EnabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - !Ref LambdaLogProxyLayer
      Environment:
        Variables:
          AWS_LAMBDA_EXEC_WRAPPER: /opt/entry.sh
          LOG_COUNT: "1000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /1000/enabled
            Method: get
  LambdaLogProxy1000DisabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          LOG_COUNT: "1000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /1000/disabled
            Method: get
  LambdaLogProxy10000EnabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - !Ref LambdaLogProxyLayer
      Environment:
        Variables:
          AWS_LAMBDA_EXEC_WRAPPER: /opt/entry.sh
          LOG_COUNT: "10000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /10000/enabled
            Method: get
  LambdaLogProxy10000DisabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          LOG_COUNT: "10000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /10000/disabled
            Method: get
  LambdaLogProxy100000EnabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - !Ref LambdaLogProxyLayer
      Environment:
        Variables:
          AWS_LAMBDA_EXEC_WRAPPER: /opt/entry.sh
          LOG_COUNT: "100000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /100000/enabled
            Method: get
  LambdaLogProxy100000DisabledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          LOG_COUNT: "100000"
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /100000/disabled
            Method: get

Outputs:
  API:
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"