Skip to main content

Based on EventBridge rule, automatically set the logGroup retention policy when new AWS CloudWatch logGroup is created.

Project description

Cloudwatch Retention Setter

releasenpm versionPyPI version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rantoniuk.cloudwatch-retention-setter-1.0.0.tar.gz (62.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file rantoniuk.cloudwatch-retention-setter-1.0.0.tar.gz.

File metadata

File hashes

Hashes for rantoniuk.cloudwatch-retention-setter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 83ecdb9d57a950547c9092cc30d8b1bef38afd366163e9edf34ac37f9fe4eb25
MD5 7f453173e621623a0ba3d5af12e05e5a
BLAKE2b-256 82b788cb283f59663be433b6fab943b0ae087b3661b0293085e21f984aa96604

See more details on using hashes here.

File details

Details for the file rantoniuk.cloudwatch_retention_setter-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rantoniuk.cloudwatch_retention_setter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a31e68f8d55e6616afc2d3c6de751173432152f628d0a87f040a0cf5ee8bb9b1
MD5 3569f977536290b1f5b0778e5c53ef07
BLAKE2b-256 8c4552ecc6f7e148473f05f2e75cdbc0edb93c7b44dfdcd3bdcd4cea350a70f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page