aws / aws/aws-cdk

(rds): Support Point-in-Time Database Cluster Recovery via L2 DatabaseCluster construct

Open
#25,998 2 comments 16 reactions 0 assignees View on GitHub
@aws-cdk/aws-rds effort/large feature-request feature/new-construct p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

As of [March 2023](https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-rds/pull/420), the `AWS::RDS::DBCluster` CloudFormation resource supports the [`RestoreToTime`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-restoretotime) property.

It would be great if there were an L2-construct (ala [`DatabaseClusterFromSnapshot`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseClusterFromSnapshot.html)) that made restoring a database to a point-in-time simpler.

### Use Case

The [`DatabaseClusterFromSnapshot`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseClusterFromSnapshot.html) construct is great if you have a snapshot you want to restore from. However, a Point-In-Time Recovery (PITR) might be preferable in disaster recovery scenarios.

### Proposed Solution

Two ideas:

1. A new `DatabaseClusterFromPointInTime` construct
2. Create a new `RestoredDatabaseCluster` construct that encapsulates restoring from a point in time _or_ a snapshot.

Creating a new construct feels more in line with what we have today for snapshots.

However, the second option feels "cleaner" because the same principals of restoring from a snapshot apply to the PITR option (a new database is created, etc.)

`RestoredDatabaseCluster` might take something like this:

```ts
export interface RestoredDatabaseProps extends DatabaseClusterBaseProps {
// provide one or the other
readonly snapshotIdentifier?: string;
readonly restoreToTime?: string;
}
```

### Other Information

Alternatively, you can reach into the L1 construct to set the `RestoreToTime` property.

In the past, to keep my database managed by CloudFormation/CDK, I've created a temporary new Database cluster via PITR (via the console), taken a snapshot, then used [`DatabaseClusterFromSnapshot`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseClusterFromSnapshot.html).

### Acknowledgements

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

### CDK version used

2.84.0

### Environment details (OS name and version, etc.)

MacOS

Contributor guide

Open the contributing guide

Research direction

Start with the DatabaseClusterFromSnapshot construct and the L1 AWS::RDS::DBCluster resource described in the issue. Compare the proposed DatabaseClusterFromPointInTime and RestoredDatabaseCluster designs, then determine how RestoreToTime should be exposed alongside snapshot restoration. Done means an L2 construct can create a cluster from a point in time while preserving CloudFormation/CDK management.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.