Skip to content

Feature request: Lambda Logs definition in template #2653

@GuidoNebiolo

Description

@GuidoNebiolo

Describe your idea/feature/enhancement

I wish the SAM Translator would generate also the CloudWatch LogGroup for a declared Lambda.
In this way the deployment will be consistent during deletion and delete also the log group.

Proposal

Additional property for AWS::Serverless::Function which generate the AWS::Logs::LogGroup associated.

Now:

  MyService:
    Type: AWS::Serverless::Function
    Properties:
      ...

  MyLogs:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub /aws/lambda/${MyService}

Proposal:

  MyService:
    Type: AWS::Serverless::Function
    Properties:
      LogGroup: enabled

or

  MyService:
    Type: AWS::Serverless::Function
    Properties:
      LogGroup:
        RetentionInDays: 7
        DeletionPolicy: Retain/Delete

Things to consider:
[ ] The SAM documentation will need to be updated
[ ] Compatibility with previous version, if the new property is not explicitly provided, the log group should not be generated

Additional Details

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions