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

[New Service]: AWS Backup Restore Testing #37662

Closed
LozanoMatheus opened this issue May 23, 2024 · 6 comments
Closed

[New Service]: AWS Backup Restore Testing #37662

LozanoMatheus opened this issue May 23, 2024 · 6 comments
Labels
new-service Introduces a new service. service/backup Issues and PRs that pertain to the backup service.
Milestone

Comments

@LozanoMatheus
Copy link

LozanoMatheus commented May 23, 2024

Description

On Nov 27 - 2023, AWS announced the AWS Backup restore testing. This can be used to automate the DR testing based on the AWS Backups. They made a blog post showing how it works.

Requested Resource(s) and/or Data Source(s)

Resource

Data

Potential Terraform Configuration

## Resource

resource "aws_backup_restore_testing_selection" "main" {
  iam_role_arn              = aws_iam_role.main.arn
  protected_resource_arns   = ["*"]
  restore_testing_plan_name = aws_backup_restore_testing_plan.main.name
  validation_window_hours   = 0
  name                      = "test" ## Must contain from 1 to 50 alphanumeric characters or underscores
  protected_resource_type   = "RDS"    ## available options: https://docs.aws.amazon.com/aws-backup/latest/devguide/API_RestoreTestingSelectionForCreate.html#Backup-Type-RestoreTestingSelectionForCreate-ProtectedResourceType
  restore_metadata_overrides {         ## available options: https://docs.aws.amazon.com/aws-backup/latest/devguide/restore-testing-inferred-metadata.html
    availability_zone  = "eu-west-1a"
    availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
    option_group_name  = "default:mysql-8-0"
  }
}

resource "aws_backup_restore_testing_plan" "main" {
  name = "test" ## Must contain from 1 to 50 alphanumeric characters or underscores
  recovery_point_selection {
    algorithm             = "LATEST_WITHIN_WINDOW"     ## available options: https://docs.aws.amazon.com/aws-backup/latest/devguide/API_RestoreTestingRecoveryPointSelection.html#Backup-Type-RestoreTestingRecoveryPointSelection-Algorithm
    recovery_point_types  = ["CONTINUOUS", "SNAPSHOT"] ## available options: https://docs.aws.amazon.com/aws-backup/latest/devguide/API_RestoreTestingRecoveryPointSelection.html#Backup-Type-RestoreTestingRecoveryPointSelection-RecoveryPointTypes
    exclude_vaults        = []
    include_vaults        = ["*"]
    selection_window_days = 7
  }
  schedule_expression          = "cron(0 12 * * ? *)"
  schedule_expression_timezone = "UTC"
  start_window_hours           = 0
}

## Data

data "aws_backup_restore_testing_plan" "main" {
  name = "test"
}

data "aws_backup_restore_testing_selection" "main" {
  name                      = "test"
  restore_testing_plan_name = aws_backup_restore_testing_plan.main.name
}

data "aws_backup_restore_testing_plans" "main" {}

data "aws_backup_restore_testing_selections" "main" {
  restore_testing_plan_name = aws_backup_restore_testing_plan.main.name
}

References

AWS Go SDK v2

Create:

Delete:

Get:

List:

Update:

AWS CLI examples

AWS CLI version 2.15.56.

Ordered by execution, like create, get, list, update, and delete.

Create:

  • CreateRestoreTestingPlan
aws backup \
    create-restore-testing-plan \
    --restore-testing-plan 'RecoveryPointSelection={Algorithm=LATEST_WITHIN_WINDOW,ExcludeVaults=[],IncludeVaults=[*],RecoveryPointTypes=["SNAPSHOT","CONTINUOUS"],SelectionWindowDays=7},RestoreTestingPlanName="test001",ScheduleExpression="cron(30 0 ? * * *)",ScheduleExpressionTimezone="Europe/Amsterdam",StartWindowHours=8'
  • CreateRestoreTestingSelection
aws backup \
    create-restore-testing-selection \
    --restore-testing-plan-name "test001" \
    --restore-testing-selection 'IamRoleArn="arn:aws:iam::<MY_AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>",ProtectedResourceArns='["*"]',ProtectedResourceType="RDS",RestoreMetadataOverrides={AvailabilityZones="[\"eu-west-1a\",\"eu-west-1b\",\"eu-west-1c\"]"},RestoreTestingSelectionName="test001",ValidationWindowHours=0'

Get:

  • GetRestoreTestingPlan
aws backup \
    get-restore-testing-plan \
    --restore-testing-plan-name "test001"
  • GetRestoreTestingSelection
aws backup \
    get-restore-testing-selection \
    --restore-testing-plan-name "test001" \
    --restore-testing-selection-name "test001"

List:

  • ListRestoreTestingPlans
aws backup \
    list-restore-testing-plans
  • ListRestoreTestingSelections
aws backup \
    list-restore-testing-selections \
    --restore-testing-plan-name "test001"

Update:

  • UpdateRestoreTestingPlan
aws backup \
    update-restore-testing-plan \
    --restore-testing-plan-name "test001" \
    --restore-testing-plan 'RecoveryPointSelection={Algorithm=LATEST_WITHIN_WINDOW,ExcludeVaults=[],IncludeVaults=[*],RecoveryPointTypes=["SNAPSHOT"],SelectionWindowDays=7},ScheduleExpression="cron(30 0 ? * * *)",ScheduleExpressionTimezone="UTC",StartWindowHours=1'

# --restore-testing-plan-name ## The name of the restore testing plan to update
# --restore-testing-plan      ## New values you want to update
  • UpdateRestoreTestingSelection
aws backup \
    update-restore-testing-selection \
    --restore-testing-plan-name "test001" \
    --restore-testing-selection-name "test001" \
    --restore-testing-selection 'IamRoleArn="arn:aws:iam::<MY_AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>",ProtectedResourceArns='["*"]',RestoreMetadataOverrides={AvailabilityZones="[\"eu-west-1a\"]",optionGroupName="default:mysql-8-0"},ValidationWindowHours=3'

# --restore-testing-plan-name       ## The name of the restore-testing plan
# --restore-testing-selection-name  ## The name of the restore testing selection to update 
# --restore-testing-selection       ## New values you want to update

Delete:

  • DeleteRestoreTestingSelection

This needs to be deleted first, otherwise, you'll get the error An error occurred (InvalidRequestException) when calling the DeleteRestoreTestingPlan operation: Related restore testing selections must be deleted prior to deleting restore testing plan [test001].

aws backup \
    delete-restore-testing-selection \
    --restore-testing-plan-name "test001" \
    --restore-testing-selection-name "test001"
  • DeleteRestoreTestingPlan
aws backup \
    delete-restore-testing-plan \
    --restore-testing-plan-name "test001" \

Would you like to implement a fix?

No

@github-actions github-actions bot added the service/backup Issues and PRs that pertain to the backup service. label May 23, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 23, 2024
@LozanoMatheus
Copy link
Author

Duplicated with #34699. PR == #37039.

@justinretzolk justinretzolk added new-service Introduces a new service. and removed needs-triage Waiting for first response or review from a maintainer. labels May 24, 2024
@ewbankkit
Copy link
Contributor

Closed via #37039.

@ewbankkit ewbankkit added this to the v5.71.0 milestone Oct 7, 2024
Copy link

github-actions bot commented Oct 7, 2024

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

Copy link

This functionality has been released in v5.72.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-service Introduces a new service. service/backup Issues and PRs that pertain to the backup service.
Projects
None yet
Development

No branches or pull requests

3 participants