aboutsummaryrefslogtreecommitdiff
path: root/terraform/admin/backups.nix
blob: ae021e5139a3f56e115983e5d5b7af569a4f49bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ lib, ... }:
{
  resource.google_storage_bucket.backups = {
    name = "fcuny-infra-backups";
    storage_class = "NEARLINE";
    force_destroy = true;
    uniform_bucket_level_access = true;
    public_access_prevention = "enforced";
    location = lib.tfRef "var.gcp_region";

    lifecycle_rule = [
      {
        condition.age = 365; # After 1 year
        action = {
          type = "SetStorageClass";
          storage_class = "COLDLINE";
        };
      }
      {
        condition.age = 730; # After 2 years
        action = {
          type = "SetStorageClass";
          storage_class = "ARCHIVE";
        };
      }
    ];
  };
}