google_bigtable_gc_policy

Creates a Google Cloud Bigtable GC Policy inside a family. For more information see the official documentation and API.

Example Usage

resource "google_bigtable_instance" "instance" {
  name = "tf-instance"
  cluster {
    cluster_id   = "tf-instance-cluster"
    num_nodes    = 3
    storage_type = "HDD"
  }
}

resource "google_bigtable_table" "table" {
  name          = "tf-table"
  instance_name = google_bigtable_instance.instance.name

  column_family {
    family = "name"
  }
}

resource "google_bigtable_gc_policy" "policy" {
  instance_name = google_bigtable_instance.instance.name
  table         = google_bigtable_table.table.name
  column_family = "name"
  deletion_policy = "ABANDON"


  gc_rules = <<EOF
  {
    "rules": [
      {
        "max_age": "168h"
      }
    ]
  }
  EOF
}
  {
    "rules": [
      {
        "max_age": "168h"
      }
    ]
  }
  EOF
}

Multiple conditions is also supported. UNION when any of its sub-policies apply (OR). INTERSECTION when all its sub-policies apply (AND)

resource "google_bigtable_gc_policy" "policy" {
  instance_name = google_bigtable_instance.instance.name
  table         = google_bigtable_table.table.name
  column_family = "name"
  deletion_policy = "ABANDON"

  gc_rules = <<EOF
  {
    "mode": "union",
    "rules": [
      {
        "max_age": "168h"
      },
      {
        "max_version": 10
      }
    ]
  }
  EOF
}
  {
    "mode": "union",
    "rules": [
      {
        "max_age": "168h"
      },
      {
        "max_version": 10
      }
    ]
  }
  EOF
}

An example of more complex GC policy:

resource "google_bigtable_instance" "instance" {
  name = "instance_name"

  cluster {
    cluster_id = "cid"
    zone       = "us-central1-b"
  }

  instance_type = "DEVELOPMENT"
  deletion_protection = false
}

resource "google_bigtable_table" "table" {
  name          = "your-table"
  instance_name = google_bigtable_instance.instance.id

  column_family {
    family = "cf1"
  }
}

resource "google_bigtable_gc_policy" "policy" {
  instance_name = google_bigtable_instance.instance.id
  table         = google_bigtable_table.table.name
  column_family = "cf1"
  deletion_policy = "ABANDON"

  gc_rules = <<EOF
  {
    "mode": "union",
    "rules": [
      {
        "max_age": "10h"
      },
      {
        "mode": "intersection",
        "rules": [
          {
            "max_age": "2h"
          },
          {
            "max_version": 2
          }
        ]
      }
    ]
  }
  EOF
}
  {
    "mode": "union",
    "rules": [
      {
        "max_age": "10h"
      },
      {
        "mode": "intersection",
        "rules": [
          {
            "max_age": "2h"
          },
          {
            "max_version": 2
          }
        ]
      }
    ]
  }
  EOF
}

This is equivalent to running the following cbt command:

cbt setgcpolicy your-table cf1 "(maxage=2d and maxversions=2) or maxage=10h"

Argument Reference

The following arguments are supported:


max_age supports the following arguments:


max_version supports the following arguments:


gc_rules include 2 fields:

Attributes Reference

Only the arguments listed above are exposed as attributes.

Timeouts

This resource provides the following Timeouts configuration options:

Import

This resource does not support import.