aws / aws/aws-sdk-java-v2

Support setting CloudWatch Logs Export retention period in RDS clients

Open
#4,727 1 comment 1 reaction 0 assignees View on GitHub
feature-request service-api service:rds
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

### Describe the feature

When using the Java SDK v2 to create or restore a DB cluster the API allows the user to specify the list of log types that need to be enabled for exporting to CloudWatch Logs. However the API does not allow to specify the retention period for these exported logs. Therefore the Log Groups are created with the default retention policy which is `never expire`.

Please consider adding an option to also allow the caller to specify the retention period (the CDK supports this) as part of the RDS clients Java API.

### Use Case

When creating or restoring a DB cluster via the Java v2 SDK, we cannot specify the retention period for exported logs to CloudWatch. In order to ensure we don't store these indefinitely we have to manually build the log group names from the cluster identifier, loop over the LogGroups, and use the CloudWatchLogs API to ensure the Log Groups generated for the configured exported CloudWatch Logs have the correct retention policy assigned.

### Proposed Solution

It would be convenient if the RDS client would allow one to set the retention period for the LogGroups created by specifying `enableCloudWatchLogsExport`.

For example the API could offer a new method which can be used as part of the request to specify how long one wants to retain the exported logs in CloudWatch.

```java
cloudWatchLogsExportRetentionPeriod(Integer cloudWatchLogsExportRetentionPeriod)
```

```java
RestoreDbClusterToPointInTimeRequest.builder()
......
.enableCloudWatchLogsExports("audit","error","general","slowquery")
.cloudWatchLogsExportRetentionPeriod(14) // Keep exported logs for a period of 14 days in CloudWatch
.....
.build();
```

If not specified the current behaviour can remain in tact to avoid breaking existing implementations.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS Java SDK version used

2.17.257

### JDK version used

Corretto-11.0.21.9.1

### Operating System and version

macOS Sonoma 14.1.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.