-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
resource/aws_db_instance: Replicated automated backups as a source for the option restore_to_point_in_time #21851
Comments
@jonasoneves Were you able to find a solution to restore an automated backup in another region? |
@mzazon I've been generating a script to run the restore via AWS cli commands with the terraform resource local_file, which then import the new RDS to terraform automatically. It lives in the same module as the RDS instance (so it can get variables like rds-identifier, security-groups, etc.) resource "local_file" "this" {
content = <<SCRIPT
#!/bin/bash
export AWS_DEFAULT_REGION=${var.region}
export AWS_DEFAULT_OUTPUT=text
AUTO_BACKUP_ARN=$(aws rds describe-db-instance-automated-backups \
--db-instance-identifier ${var.db_identifier} \
--query DBInstanceAutomatedBackups[*].DBInstanceAutomatedBackupsArn)
aws rds restore-db-instance-to-point-in-time \
--db-subnet-group-name ${var.subnet_group} \
--multi-az \
--source-db-instance-automated-backups-arn "$AUTO_BACKUP_ARN" \
--target-db-instance-identifier ${var.db_identifier} \
--use-latest-restorable-time \
--vpc-security-group-ids ${join(",", var.security_group_ids)}
echo -e "\nImporting new RDS instance to terraform state..."
terraform import module.rds.module.db_instance.aws_db_instance.this[0] ${var.db_identifier}
SCRIPT
filename = "restore-backup.sh"
} |
@jonasoneves great solution, thank you! we are doing similar although a bit more manual. I may take a stab at creating a pull request for this parameter if I have time this week. |
This functionality has been released in v4.6.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! |
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. |
Community Note
Description
The AWS RDS API action RestoreDBInstanceToPointInTime supports the request parameter SourceDBInstanceAutomatedBackupsArn, which is currently not a valid option in the terraform aws provider. This allows restoring backups replicated from a different region.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: