Based on EventBridge rule, automatically set the logGroup retention policy when new AWS CloudWatch logGroup is created.
Project description
Cloudwatch Retention Setter
Cloudwatch Retention Setter is an AWS CDK construct library that reacts on AWS CloudWatch events. AWS CloudWatch does not offer the ability to set a "default retention policy" that would be set to all newly created Log Groups (e.g. by Lambda Function runs).
This construct addresses this by monitoring AWS CloudWatch Events via EventBridge, when a new LogGroup is created a Lambda function is invoked automatically that sets the retention policy to the specified value.
Getting started
TypeScript
Installation
npm:
npm install --save cloudwatch-retention-setter
yarn:
yarn add cloudwatch-retention-setter
Usage
import * as cdk from 'aws-cdk-lib';
import { CloudwatchRetentionSetter } from 'cloudwatch-retention-setter';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { Schedule } from 'aws-cdk-lib/aws-events';
const app = new cdk.App();
const stack = new cdk.Stack(app, '<stack-name>');
// use default retention of 6 months
new CloudwatchRetentionSetter(stack, 'cloudwatch-retention-setter');
// use custom retention
new CloudwatchRetentionSetter(stack, 'cloudwatch-retention-setter', {
retentionDays: RetentionDays.ONE_MONTH,
});
Python
Installation
$ pip install cloudwatch-retention-setter
Usage
import aws_cdk.core as cdk
from cdk_cloudwatch_retention_setter import CloudwatchRetentionSetter
app = cdk.App()
stack = cdk.Stack(app, "<stack-name>")
CloudwatchRetentionSetter(stack, "cloudwatch-retention-setter")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rantoniuk.cloudwatch-retention-setter-1.0.0.tar.gz.
File metadata
- Download URL: rantoniuk.cloudwatch-retention-setter-1.0.0.tar.gz
- Upload date:
- Size: 62.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83ecdb9d57a950547c9092cc30d8b1bef38afd366163e9edf34ac37f9fe4eb25
|
|
| MD5 |
7f453173e621623a0ba3d5af12e05e5a
|
|
| BLAKE2b-256 |
82b788cb283f59663be433b6fab943b0ae087b3661b0293085e21f984aa96604
|
File details
Details for the file rantoniuk.cloudwatch_retention_setter-1.0.0-py3-none-any.whl.
File metadata
- Download URL: rantoniuk.cloudwatch_retention_setter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 61.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31e68f8d55e6616afc2d3c6de751173432152f628d0a87f040a0cf5ee8bb9b1
|
|
| MD5 |
3569f977536290b1f5b0778e5c53ef07
|
|
| BLAKE2b-256 |
8c4552ecc6f7e148473f05f2e75cdbc0edb93c7b44dfdcd3bdcd4cea350a70f5
|