Lambda@Edge log retention and serverless dashboard monitoring

I have a Lambda function that is deployed to us-east-1 (global location for @Edge lambdas) and used as @Edge one with Cloudfront distribution. It is deployed with Serverless using the below configuration and then manually bound to the Cloudfront behaviour.

serverless.yml config:

provider:
  name: aws
  runtime: nodejs10.x
  region: us-east-1
  memorySize: 128
  timeout: 5
  logRetentionInDays: 7
(...)
functions:
  my_viewer_request:
    handler: viewer-request.handler

resources:
  Resources:
    IamRoleLambdaExecution:
      Type: "AWS::IAM::Role"
      Properties:
        AssumeRolePolicyDocument:
          Statement:
            - Effect: "Allow"
              Principal:
                Service:
                  - "lambda.amazonaws.com"
                  - "edgelambda.amazonaws.com"
              Action:
                - "sts:AssumeRole"

This works nicely but there is an issue with log retention. Log retention period is only set for the use-east-1 region while in other regions (as this is @Edge function so it creates logs in multiple regions) log groups are always created with the ‘never expire’ setting. Is there any way to change this behaviour?

I’ve tried to create Lambda@Edge function with Serverless AWS cloudFront event (as described in https://serverless.com/blog/lambda-at-edge-support-added/) but the same thing happens (logRetention is only set for us-east-1).

The second issue that seems to be related is the lack of monitoring in the Serverless dashboard (seems it doesn’t track other locations than us-east-1).

1 Like