Description
Aurora always takes automated backups and retains them for 1–35 days. With AWS provider v6.14.0, omitting aws_rds_cluster.backup_retention_period selects one day.
Potential impact
A one-day window can expire before you discover a problem. The required recovery point may then be unavailable.
Remediation
- Set
backup_retention_periodexplicitly according to the service’s recovery needs. Apply the same retention standard to comparable environments. - Check the cluster’s earliest and latest restorable times. Regularly restore a new cluster to a time within that range.
Examples
Supply the Aurora instances and networking separately, and choose Availability Zones in the selected Region. Pass an engine-compatible password through var.db_password and protect the Terraform state that can contain it.
Use default retention
hcl
resource "aws_rds_cluster" "example" {
cluster_identifier = "aurora-cluster-demo"
engine = "aurora-postgresql"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
database_name = "mydb"
master_username = "foo"
master_password = var.db_password
preferred_backup_window = "07:00-09:00"
}
Specify retention
hcl
resource "aws_rds_cluster" "example" {
cluster_identifier = "aurora-cluster-demo"
engine = "aurora-postgresql"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
database_name = "mydb"
master_username = "foo"
master_password = var.db_password
backup_retention_period = 5
preferred_backup_window = "07:00-09:00"
}
The first cluster uses the one-day provider default. The second keeps five days of backups.