aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.17k stars 840 forks source link

Support setting CloudWatch Logs Export retention period in RDS clients #4727

Open huber-th opened 10 months ago

huber-th commented 10 months ago

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

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

debora-ito commented 1 month ago

8 months later... @huber-th I apologize for leaving a comment after so long.

This would be a feature request for the RDS team, they need to change the api to support the retention period. I'll reach out to the RDS team internally and update here when I hear back.