Skip to content

gcp-sql-backup-off

Ensure all Cloud SQL database instance have backup configuration enabled

It is recommended to turn on automatic backups of your Cloud SQL instance so that you can quickly rebuild your database in case of an attack leading to a destruction or unauthorized modification of your data.

Examples

Insecure Example

resource "google_sql_database_instance" "my-db" {
  name             = "my-db"
  database_version = "MYSQL_8_0"
  region           = "us-cenral1"

  settings {
    tier              = "db-f1-micro"
    availability_type = "REGIONAL"

    backup_configuration {
      enabled = false
    }
  }
}

Secure Example

resource "google_sql_database_instance" "my-db" {
  name             = "my-db"
  database_version = "MYSQL_8_0"
  region           = "us-cenral1"

  settings {
    tier              = "db-f1-micro"
    availability_type = "REGIONAL"

    backup_configuration {
      enabled = true
    }
  }
}

More information