in packages/app/src/handlers/set-retention.ts [11:40]
export async function setRetention(): Promise<void> {
const clientConfig = awsClientConfig();
const cloudwatchLogs = new CloudWatchLogs(clientConfig);
const { retentionInDays } = getSetRetentionConfig();
const cloudwatchLogGroups = await getCloudWatchLogGroups(cloudwatchLogs);
for (const logGroup of cloudwatchLogGroups) {
if (logGroup.logGroupName === undefined) {
break; // cannot do anything
}
if (logGroup.retentionInDays === retentionInDays) {
console.log(
`Log group ${logGroup.logGroupName} retention is already ${retentionInDays} days`,
);
} else {
await setCloudwatchRetention(
cloudwatchLogs,
logGroup.logGroupName,
retentionInDays,
);
// avoid hitting the SDK throttling limit
await sleep(200);
console.log(
`Set ${logGroup.logGroupName} retention to ${retentionInDays} days`,
);
}
}
}