There is a way to set automatic log expiring for cloudwatch logs on jets?
How I could do it?
Thanks
There is a way to set automatic log expiring for cloudwatch logs on jets?
How I could do it?
Thanks
Setting the log expiring for cloudwatch logs created by Jets is not currently supported.
Dug into this a little bit and it looks like it involves explicitly creating AWS::Logs::LogGroup
resource associated with each generated Lambda Function. So it’s possible. Though, am little hesitant right now to the additional AWS::Logs::LogGroup
because CloudFormation currently supports 200 resources for each template. See CloudFormation Limits Resources.
With the way Jets is designed, we’re not near the limit but am wondering if it’s worth it to effectively double the resource count for this feature. Maybe it should be done with a direct API call as an internal post deploy hook. Ultimately, would like to have a more general hook system and am hoping to extract it out from concrete use case implementations.
Anyway, TLDR: Setting the CloudWatch Log Group expiry is not currently supported.
Here’s a command that can be ran to set the CloudWatch Log groups expiration manually post deploy. It uses aws logs put-retention-policy. It’s a workaround:
NAMESPACE="demo-dev-"
RETENTION_DAYS=7
for i in $(aws logs describe-log-groups | jq -r '.logGroups[].logGroupName' | grep $NAMESPACE) ; do echo $i ; aws logs put-retention-policy --log-group-name $i --retention-in-days $RETENTION_DAYS ; done
Hope that helps.
It works very well, thanks!