Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Add DevX Backups support to RDS instance construct #2276

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

jacobwinch
Copy link
Contributor

@jacobwinch jacobwinch commented Apr 15, 2024

What does this change?

This PR adds support for DevX Backups to our RDS instance construct. Users are now forced to opt-in/out of backups when provisioning an RDS instance via this construct. This makes it less likely that we will forget to add protection to important backups. Users who choose to provision an RDS instance via an AWS construct (instead of the GuCDK one) can still currently forget to make this choice (we will improve this in a follow up PR by modifying this aspect to check for the presence of the correct tag).

Additionally, we help to avoid conflicts by preventing users who opt-in to this feature from setting native RDS backup properties that cannot be managed via CloudFormation once AWS Backup is enabled. Users who opt-out of DevX Backups are still able to set these properties as there is no conflict.

The deletion of automated backups (on instance deletion) is now prevented by default (i.e. we override the CFN default). This is necessary where DevX Backups are enabled (the lock on these backups will prevent the instance from being deleted otherwise). In cases where users have opted-out of DevX Backups I still consider retaining the automated backups to be a sensible precaution so I have not made this change conditional.

Finally, I've removed some old unit tests that seemed to be testing functionality that is provided via the AWS libraries rather than our own construct: c5f348e.

How to test

I've added unit tests to cover the new functionality.

How can we measure success?

Users provisioning new RDS instances via GuCDK will be more likely to remember to opt-in to DevX Backups.

Have we considered potential risks?

This construct is not widely used and opting-in is an easy change, so I don't think this breaking change poses much of a risk in terms of generating work for teams.

Checklist

  • I have listed any breaking changes, along with a migration path 1
  • I have updated the documentation as required for the described changes 2

Footnotes

  1. Consider whether this is something that will mean changes to projects that have already been migrated, or to the CDK CLI tool. If changes are required, consider adding a checklist here and/or linking to related PRs.

  2. If you are adding a new construct or pattern, has new documentation been added? If you are amending defaults or changing behaviour, are the existing docs still valid?

Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: 69ec42c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@guardian/cdk Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

BREAKING CHANGE:

Users of the GuDatabaseInstance class now need to explicitly opt-in/out of
DevX Backups via the devXBackups prop.

export interface GuDatabaseInstanceProps
extends Omit<DatabaseInstanceProps, "instanceType" | "backupRetention" | "preferredBackupWindow">,
AppIdentity {
instanceType: string;
Copy link
Contributor Author

@jacobwinch jacobwinch Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a shame that we are removing the InstanceType type from instanceType and making it a string instead - I'd like to change this but it'd be a breaking change and is not linked to the PR, so have left it as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on both counts.

@jacobwinch jacobwinch marked this pull request as ready for review April 15, 2024 16:33
@jacobwinch jacobwinch changed the title Add DevX Backups support to RDS instance construct feat!: Add DevX Backups support to RDS instance construct Apr 15, 2024
Copy link

@adamnfish adamnfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

Ref: Match.stringLikeRegexp("DatabaseInstanceTestingParameterGroup[A-Z0-9]+"),
},
console.log(JSON.stringify(stack.tags.tagValues()));
GuTemplate.fromStack(stack).hasGuTaggedResource("AWS::RDS::DBInstance", {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add functionality to check for a single tag, but no worries here! This would encourage good test practice (one assertion per test), and eliminate noise from cases like this one where we are focused on a single tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamnfish - there's a suggestion for this here: #2280.

@jacobwinch jacobwinch merged commit 7cc8591 into main Apr 17, 2024
2 checks passed
@jacobwinch jacobwinch deleted the jw-rds-construct branch April 17, 2024 10:08
Copy link
Contributor

@michaelwmcnamara michaelwmcnamara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants