Is it possible to specify log retention for a crea...
# help
ö
Is it possible to specify log retention for a created stack? All I could find for specifying the log retention for a
SAM
app is this repository in SAR: https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:374852340823:applications~auto-set-log-group-retention So I have two questions. 1. How can I see the current retention for a stack? 2. Can I change it without per stack without specifying every log group for a function one by one?
r
I've been wondering the same but hadn't gotten around to asking the question You can create a CDK log group and set a retention like this:
Copy code
import * as logs from "@aws-cdk/aws-logs";    
const log = new logs.LogGroup(this, 'myLogGroup', {
  retention: logs.RetentionDays.FIVE_DAYS,
});
But I'm not sure how to apply that to the SST stack
f
Hey @Ömer Toraman just to clarify, you are looking to set log retention for lambda functions right?
r
Just spotted there's a logRetention property in props for sst.Function. Not sure how to specify for the API log access logs though
ö
Hey @Frank , yes exactly, basically determining for how long CloudWatch will store the logs.
f
@Ross Coundon, yeah we are going to add an option to the
Api
construct - https://github.com/serverless-stack/serverless-stack/issues/856
@Ömer Toraman you can set
logRetention
in ur function, ie.
Copy code
{
  logRetention: logs.RetentionDays.THREE_DAYS,
}