Set log retention for custom resources
Now the logs for custom resources never expire. However, most of them won't make any sense after 30/60 days after deployment. And users need to clean those log groups periodically. It would be great if we can set log retention for custom resource log group by default.
@iamhopaul123 any insight into whether this will be prioritized?
Hello @rymndhng !
You can set the Logging configuration of lambda using yaml patch overrides
For example
- op: add
path: /Resources/EnvControllerFunction/Properties/LoggingConfig
value:
ApplicationLogLevel: TRACE
LogFormat: <optional custom format>
LogGroup: <custom log group name>
SystemLogLevel: WARN
And a log group with retention of 30 days.
- op: add
path: /Resources/EnvControllerLogGroup
value:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Join ['', [/copilot/, !Ref AppName, '-', !Ref EnvName, '-controller']]
RetentionInDays: 30
docs: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-loggingconfig.html#cfn-lambda-function-loggingconfig-loggroup