RDS instance automated backups disabled

Set a positive automated backup retention period that meets the RDS instance’s recovery requirements.

Description

For aws_db_instance, backup_retention_period = 0 disables automated backups. In AWS provider v6.14.0, zero is also the default when the field is omitted.

Potential impact

After a failure or data loss, manual snapshots can restore only the times they captured. Changes made between those snapshots may be lost.

Remediation

  • Set backup_retention_period explicitly to 1–35 days according to the database’s recovery requirements.
  • Schedule downtime when changing between zero and a positive value. Check backup completion and available restore times, then test a restore. Manage manual snapshot retention separately.

Examples

Check regional support for the example’s MySQL 5.7 and db.t2.micro. Configure networking, pass a valid password securely through var.db_password, and protect the Terraform state that can contain it.

Before

hcl
resource "aws_db_instance" "example" {
  allocated_storage       = 20
  storage_type            = "gp2"
  engine                  = "mysql"
  engine_version          = "5.7"
  instance_class          = "db.t2.micro"
  db_name                 = "mydb"
  username                = "foo"
  password                = var.db_password
  backup_retention_period = 0
}

After

hcl
resource "aws_db_instance" "example" {
  allocated_storage       = 20
  storage_type            = "gp2"
  engine                  = "mysql"
  engine_version          = "5.7"
  instance_class          = "db.t2.micro"
  db_name                 = "mydb"
  username                = "foo"
  password                = var.db_password
  backup_retention_period = 12
}

The first instance disables automated backups. The second retains them for 12 days.

References