# cloudwatch-retention-setter

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

Latest version **1.0.0** (published 2024-05-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install cloudwatch-retention-setter
pnpm add cloudwatch-retention-setter
yarn add cloudwatch-retention-setter
bun add cloudwatch-retention-setter
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-05-29 |
| First published | 2022-10-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 151.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Radek Antoniuk |
| Maintainers | rantoniuk |
| Keywords | cdk |

## Links

- npm: https://www.npmjs.com/package/cloudwatch-retention-setter
- Repository: https://github.com/rantoniuk/cloudwatch-retention-setter
- Homepage: https://github.com/rantoniuk/cloudwatch-retention-setter#readme
- Issues: https://github.com/rantoniuk/cloudwatch-retention-setter/issues
- npm.io page: https://npm.io/package/cloudwatch-retention-setter

## Recent versions

- 1.0.0 (latest) — 2024-05-29
- 0.0.15 — 2024-04-04
- 0.0.14 — 2023-06-25
- 0.0.13 — 2023-04-18
- 0.0.12 — 2023-03-29
- 0.0.11 — 2023-02-07
- 0.0.10 — 2023-02-06
- 0.0.9 — 2023-02-02
- 0.0.8 — 2023-01-13
- 0.0.7 — 2022-10-25
- 0.0.6 — 2022-10-22
- 0.0.5 — 2022-10-21
- 0.0.4 — 2022-10-21
- 0.0.3 — 2022-10-21
- 0.0.2 — 2022-10-21
- … 2 more at https://npm.io/package/cloudwatch-retention-setter/versions

## README

# Cloudwatch Retention Setter

![release](https://github.com/rantoniuk/cloudwatch-retention-setter/actions/workflows/release.yml/badge.svg)[![npm version](https://badge.fury.io/js/cloudwatch-retention-setter.svg)](https://badge.fury.io/js/cloudwatch-retention-setter)[![PyPI version](https://badge.fury.io/py/cloudwatch-retention-setter.svg)](https://badge.fury.io/py/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.

![](https://raw.githubusercontent.com/rantoniuk/cloudwatch-retention-setter/main/img/arch.png)

## Getting started

### TypeScript

#### Installation

npm:

```
npm install --save cloudwatch-retention-setter
```

yarn:

```
yarn add cloudwatch-retention-setter
```

#### Usage

```typescript
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

```bash
$ pip install cloudwatch-retention-setter
```

#### Usage

```python
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")
```

---
_Source: https://npm.io/package/cloudwatch-retention-setter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
