aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.62k stars 3.91k forks source link

RDS: Is it possible to specify LogGroup RetentionDays for ServerlessCluster? #22662

Open johnnynanjiang opened 1 year ago

johnnynanjiang commented 1 year ago

Describe the feature

I can only see the logs for current day for my ServerlessCluster. What is the default days for its LogGroup?

/aws/rds/cluster/???/postgresql

Use Case

Would like the ability to retain the LogGroup for a certain period of time for auditing purpose.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

1.140.0

Environment details (OS name and version, etc.)

n/a

peterwoodworth commented 1 year ago

This currently isn't possible - the DatabaseCluster construct has additional logic and props that the ServerlessCluster construct does not contain: https://github.com/aws/aws-cdk/blob/3528e3de5b5dd0a520624d4af73413370dcdc434/packages/%40aws-cdk/aws-rds/lib/cluster.ts#L802

I'm not 100% sure if we can bring this same feature to ServerlessCluster or if it was left out intentionally. It doesn't seem to me that there's a reason to not support this though, please let me know if anyone knows otherwise 🙂

Jacco commented 1 year ago

I have an update on this issue, the AWS documentation is not very clear on this subject.

After adding the enableCloudwatchLogsExports property to the ServerlessCluster class I ran an integration test to see if I would get errors and I received the following error from CloudFormation:

"Aurora Serverless currently doesn't support CloudWatch Log Export.
(Service: Rds, Status Code: 400, Request ID: dd01f3db-394e-4c42-86e2-afa6d310194a)"

Serverless Clusters do however create logs in CloudWatch I saw at least the

/aws/rds/cluster/data-basename/error

LogGroup.

It might be the case that also additional logs can go to Cloudwatch but that they are based on ParameterGroups

The error log indeed has a retention of infinite.

Maybe something can be done with LogRetention still if we can know exactly what logs the ServerlessCluster will have.