aws-sdk-java-v2
aws-sdk-java-v2 copied to clipboard
Support setting CloudWatch Logs Export retention period in RDS clients
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.
cloudWatchLogsExportRetentionPeriod(Integer cloudWatchLogsExportRetentionPeriod)
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