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(backup): support continuous backup and point-in-time restores #17602

Merged
merged 9 commits into from
Dec 17, 2021

Conversation

jumic
Copy link
Contributor

@jumic jumic commented Nov 19, 2021

Adds support for continuous backup and point-in-time restores.

Implemented validations when continuous backup and point-in-time restores is enabled:

  • deleteAfter between 1 and 35 days. "The minimum retention period is 1 day. The maximum retention period is 35 days." (see docs)
  • deleteAfter must be specified. Mandatory in AWS console. CloudFormation error if not specified: Lifecycle must be specified for backup rule enabled continuous backup
  • moveToColdStorageAfter is not supported. Field not available in AWS console. CloudFormation error if specified: MoveToColdStorageAfterDays is unavailable

Closes #15922.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Nov 19, 2021

@jumic jumic changed the title feat(backup): support continuous backup and point-in-time restores feat(backupplan): support continuous backup and point-in-time restores Nov 19, 2021
@github-actions github-actions bot added the @aws-cdk/aws-backup Related AWS Backup label Nov 19, 2021
@jumic jumic changed the title feat(backupplan): support continuous backup and point-in-time restores feat(backup): support continuous backup and point-in-time restores Nov 19, 2021
@kaizencc kaizencc self-requested a review November 30, 2021 22:57
@kaizencc kaizencc added effort/small Small work item – less than a day of effort p2 labels Nov 30, 2021
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed PR description, it was very helpful. My main comment is that I think we should default deleteAfter to Duration.days(35) if not supplied. We should still be documenting these limitations both in the README and in the docstring as well, though.

packages/@aws-cdk/aws-backup/lib/rule.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-backup/lib/rule.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-backup/lib/rule.ts Show resolved Hide resolved
packages/@aws-cdk/aws-backup/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-backup/README.md Outdated Show resolved Hide resolved
@mergify mergify bot dismissed kaizencc’s stale review December 8, 2021 19:25

Pull request has been modified.

@jumic jumic requested a review from kaizencc December 8, 2021 19:26
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

This looks great @jumic! Just a few more minor nits.

}

if (props.enableContinuousBackup && props.deleteAfter &&
((props.deleteAfter?.toSeconds() < Duration.days(1).toSeconds() ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I would prefer just props.deleteAfter?.toDays() < 1 || props.deleteAfter?.toDays() > 35

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to change it. Now, the test case failed with message
Received message: "'12 hours' cannot be converted into a whole number of days.".
Should I change it anyway? I would prefer the existing solution because it shows a clear error message.

Copy link
Contributor

Choose a reason for hiding this comment

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

This actually requires some more investigation. Can you confirm the granularity that deleteAfter allows? I know its called deleteAfterDays on cloudformation but that it also accepts a double. Which makes me think we are allowed fractions of days. On our side, we convert deleteAfter to days here (so we would run into the message you got anyway):

deleteAfterDays: rule.props.deleteAfter?.toDays(),

This could be a small bug, in that our checks are more stringent then cloudformation.

If you're interested in checking this out, please do! If not, I like even more the conditional I suggested. It looks like the current CDK behavior is that deleteAfter must be a whole number of days, so it is good to stay with that level of granularity here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it as proposed. I checked some other modules in CDK where Duration is used. It's implemented in the same way.
The granularity of deleteAfter is days. Message "'12 hours' cannot be converted into a whole number of days." indicates that developers have to specify deleteAfter in days if something else is used. If this is resolved, the logic checks if deleteAfter has a valid range. So it's fine for me. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps I am misunderstanding you. But the '12 hours... error message comes from the line I linked above. It is a CDK limitation. I am weary of this because it seems like Cloudformation may allow fractions of days. This is good for now, I'll create an issue to investigate this further.

packages/@aws-cdk/aws-backup/lib/rule.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-backup/lib/rule.ts Outdated Show resolved Hide resolved
@jumic jumic requested a review from kaizencc December 14, 2021 17:57
@mergify mergify bot dismissed kaizencc’s stale review December 14, 2021 17:57

Pull request has been modified.

kaizencc
kaizencc previously approved these changes Dec 17, 2021
@mergify mergify bot dismissed kaizencc’s stale review December 17, 2021 20:13

Pull request has been modified.

@jumic
Copy link
Contributor Author

jumic commented Dec 17, 2021

Build failed (npm ERR! notarget No matching version found for @aws-cdk/aws-lex@1.135.0.). Should be solved with the current master branch.
Could you approve this PR again, please? Thanks.

@mergify
Copy link
Contributor

mergify bot commented Dec 17, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 149847b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 24c6ef5 into aws:master Dec 17, 2021
@mergify
Copy link
Contributor

mergify bot commented Dec 17, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ws#17602)

Adds support for [continuous backup and point-in-time restores](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html).

Implemented validations when continuous backup and point-in-time restores is enabled:
- `deleteAfter` between 1 and 35 days. "The minimum retention period is 1 day. The maximum retention period is 35 days." (see [docs](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html#point-in-time-recovery-working-with))
- `deleteAfter` must be specified. Mandatory in AWS console. CloudFormation error if not specified: `Lifecycle must be specified for backup rule enabled continuous backup`
- `moveToColdStorageAfter` is not supported. Field not available in AWS console. CloudFormation error if specified: `MoveToColdStorageAfterDays is unavailable`

Closes aws#15922.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-backup Related AWS Backup effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-backup): add support for EnableContinuousBackup in BackupPlanRule
3 participants