Skip to content

Can the log retention period be changed based on dev, production environment? #11

@neeraj87

Description

@neeraj87

I want to modify the log retention period based on which env my lambda is deployed for. The below is my serverless.yml code.

functions:
  myAPI:
    name: ${self:service}-${self:custom.stage}-api
    handler: build/lambda.handler
    logRetentionInDays: 14
    events:
      - http:
          method: any
          path: /api/{proxy+}
          cors:
            origins:
              - "*"
            headers:
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
            allowCredentials: true
            maxAge: 86400

As you can see the lambda is deployed to different environment which is specified by ${self:custom.stage} - the stage var is coming from a buildspec file and can have two values dev or prod.

If the stage is dev then I want the retention period to be 14 days and if its prod then 60 days. Is there a way to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions