aws / aws/serverless-application-model

Feature: Support for `RetentionInDays` and `Retain` in `LoggingConfig` for `AWS::Serverless::Function`

Open
#3,791 9 comments 2 reactions 1 assignee Claimed by @vicheey View on GitHub
contributors/welcome stage/needs-feedback type/feature
Dominant language
Python
Stars
9.6k
Forks
2.5k
Avg merge
1d 11h
Merged PRs (30d)
7

Description

### **Description:**

Currently, when defining a `AWS::Serverless::Function`, there is no native way to configure the retention period of the associated CloudWatch Log Group. The only available workaround is to manually create a corresponding `AWS::Logs::LogGroup` resource with a matching name and desired retention period. This adds complexity and creates potential deployment issues (e.g., log group already existing or being created out of order).

It would be beneficial to support log group retention directly in the `LoggingConfig` property of the `AWS::Serverless::Function` resource.

---

### **Proposed Solution:**

Extend the `LoggingConfig` property to support the following fields:

```yaml
MyFunction:
Type: AWS::Serverless::Function
Properties:
LoggingConfig:
RetentionInDays: 7 # Optional: number of days to retain logs (default: none/infinite)
Retain: true # Optional: preserve log group on resource deletion (default: false)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.