https://serverless-stack.com/ logo
#sst
Title
# sst
a

Adrián Mouly

09/16/2021, 2:58 PM
I see that SST is deploying some functions named
…LogRetentionaae0aa3c5b4d-9XyoBY3lJCKM
… Why is that? Just saw this on my Console, I have a bunch of lambdas with.
log retention
name.
t

thdxr

09/16/2021, 3:09 PM
I think this is actually coming from CDK directly, I don't recall exactly what it's used for
a

Adrián Mouly

09/16/2021, 3:46 PM
Hum.
f

Frank

09/16/2021, 11:39 PM
Yeah, so when you create a Lambda function, the log group for the function gets created by AWS Lambda on the function’s first invocation.
So when you first deploy the function, at deploy time, the log group doesn’t exist yet. So if you set the log retention for a function, CDK needs to create a custom resource that would go create the log group and sets the retention.
LogRetentionaae0aa3c5b4d-9XyoBY3lJCKM
is likely the function used by the custom resource.
a

Adrián Mouly

09/17/2021, 12:00 AM
Mmm.
But I think on SLS I also had log retention too.
And I didn’t see this procedure, could be?
I mean, thinking if CDK/SST can delete this lambda after all it’s deployed?
Just to keep a clean environment?
f

Frank

09/17/2021, 12:13 AM
Yeah, after it’s deployed, I think you can clear out the log retention setting. And the custom resource will be removed. You can give it a try.
a

Adrián Mouly

09/17/2021, 12:40 AM
You mean setting defined here?
Copy code
app.setDefaultFunctionProps(stack => {
    return {
      runtime: 'nodejs12.x',
      logRetention: RetentionDays.TWO_WEEKS,
      tracing: Tracing.DISABLED,
    };
  });
f

Frank

09/17/2021, 9:30 AM
Yup. The
logRetention
field
a

Adrián Mouly

09/17/2021, 12:29 PM
Wondering how SLS solves this? I’m using same config as used in SLS.
f

Frank

09/17/2021, 11:00 PM
Yeah, SLS always creates the LogGroup along with the functions. In your CloudFormation, you’d see a log group for each function. Where as with SST, the log groups are not in your CloudFormation, but rather created on the fly.
a

Adrián Mouly

09/18/2021, 2:52 AM
I see.
3 Views