aws-cdk-lib.aws_logs.RetentionDays

enum RetentionDays

LanguageType name
.NETAmazon.CDK.AWS.Logs.RetentionDays
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslogs#RetentionDays
Javasoftware.amazon.awscdk.services.logs.RetentionDays
Pythonaws_cdk.aws_logs.RetentionDays
TypeScript (source)aws-cdk-lib » aws_logs » RetentionDays

How long, in days, the log contents will be retained.

Example

import * as logs from 'aws-cdk-lib/aws-logs';
declare const myLogsPublishingRole: iam.Role;
declare const vpc: ec2.Vpc;

// Exporting logs from a cluster
const cluster = new rds.DatabaseCluster(this, 'Database', {
  engine: rds.DatabaseClusterEngine.aurora({
    version: rds.AuroraEngineVersion.VER_1_17_9, // different version class for each engine type
  }),
  writer: rds.ClusterInstance.provisioned('writer'),
  vpc,
  cloudwatchLogsExports: ['error', 'general', 'slowquery', 'audit'], // Export all available MySQL-based logs
  cloudwatchLogsRetention: logs.RetentionDays.THREE_MONTHS, // Optional - default is to never expire logs
  cloudwatchLogsRetentionRole: myLogsPublishingRole, // Optional - a role will be created if not provided
  // ...
});

// Exporting logs from an instance
const instance = new rds.DatabaseInstance(this, 'Instance', {
  engine: rds.DatabaseInstanceEngine.postgres({
    version: rds.PostgresEngineVersion.VER_15_2,
  }),
  vpc,
  cloudwatchLogsExports: ['postgresql'], // Export the PostgreSQL logs
  // ...
});

Members

NameDescription
ONE_DAY1 day.
THREE_DAYS3 days.
FIVE_DAYS5 days.
ONE_WEEK1 week.
TWO_WEEKS2 weeks.
ONE_MONTH1 month.
TWO_MONTHS2 months.
THREE_MONTHS3 months.
FOUR_MONTHS4 months.
FIVE_MONTHS5 months.
SIX_MONTHS6 months.
ONE_YEAR1 year.
THIRTEEN_MONTHS13 months.
EIGHTEEN_MONTHS18 months.
TWO_YEARS2 years.
THREE_YEARS3 years.
FIVE_YEARS5 years.
SIX_YEARS6 years.
SEVEN_YEARS7 years.
EIGHT_YEARS8 years.
NINE_YEARS9 years.
TEN_YEARS10 years.
INFINITERetain logs forever.

ONE_DAY

1 day.


THREE_DAYS

3 days.


FIVE_DAYS

5 days.


ONE_WEEK

1 week.


TWO_WEEKS

2 weeks.


ONE_MONTH

1 month.


TWO_MONTHS

2 months.


THREE_MONTHS

3 months.


FOUR_MONTHS

4 months.


FIVE_MONTHS

5 months.


SIX_MONTHS

6 months.


ONE_YEAR

1 year.


THIRTEEN_MONTHS

13 months.


EIGHTEEN_MONTHS

18 months.


TWO_YEARS

2 years.


THREE_YEARS

3 years.


FIVE_YEARS

5 years.


SIX_YEARS

6 years.


SEVEN_YEARS

7 years.


EIGHT_YEARS

8 years.


NINE_YEARS

9 years.


TEN_YEARS

10 years.


INFINITE

Retain logs forever.