# BigtableGCPolicy

This resource defines a Bigtable Garbage Collection (GC) policy.

> [!WARNING]
> **Warning:** We don't recommend using `maxAge`, `maxVersion` or `mode` for defining a `BigtableGCPolicy` as these fields have known drift detection issues.

> [!WARNING]
> **Warning:** We don't recommend having multiple `BigtableGCPolicy`s for the same column family as it may result in unexpected behavior.

> [!NOTE]
> **Note:** `BigtableGCPolicy`s associated with a replicated table cannot be deleted directly. Instead, you must first un-replicate the instance by updating the instance to have one cluster.

| **Property** | **Value** |
|---|---|
| Google Cloud Service Name | Cloud Bigtable |
| Google Cloud Service Documentation | [/bigtable/docs/](https://docs.cloud.google.com/bigtable/docs) |
| Google Cloud REST Resource Name | bigtableadmin/v2/projects.instances.appProfiles |
| Google Cloud REST Resource Documentation | <https://docs.cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.tables/modifyColumnFamilies#gcrule> |
| Config Connector Resource Short Names | bigtablegcpolicy gcpbigtablegcpolicies gcpbigtablegcpolicy |
| Config Connector Service Name | bigtableadmin.googleapis.com |
| Config Connector Resource Fully Qualified Name | bigtablegcpolicies.bigtable.cnrm.cloud.google.com |
| Can Be Referenced by IAMPolicy/IAMPolicyMember | No |
| Config Connector Default Average Reconcile Interval In Seconds | 600 |

## Custom Resource Definition Properties

### Annotations

| Fields ||
|---|---|
| `cnrm.cloud.google.com/project-id` |

### Spec

#### Schema

    columnFamily: string
    deletionPolicy: string
    gcRules: string
    instanceRef:
      external: string
      name: string
      namespace: string
    maxAge:
    - days: integer
      duration: string
    maxVersion:
    - number: integer
    mode: string
    tableRef:
      external: string
      name: string
      namespace: string

| Fields ||
|---|---|
| `columnFamily` *Required* | `string` Immutable. The name of the column family. |
| `deletionPolicy` *Optional* | `string` The deletion policy for the GC policy. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for GC policy as it cannot be deleted in a replicated instance. Possible values are: "ABANDON". |
| `gcRules` *Optional* | `string` Serialized JSON string for garbage collection policy. Conflicts with "mode", "max_age" and "max_version". |
| `instanceRef` *Required* | `object` The name of the Bigtable instance. |
| `instanceRef.external` *Optional* | `string` A reference to an externally managed BigtableInstance resource. |
| `instanceRef.name` *Optional* | `string` The name of a BigtableInstance resource. |
| `instanceRef.namespace` *Optional* | `string` The namespace of a BigtableInstance resource. |
| `maxAge` *Optional* | `list (object)` Immutable. NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. GC policy that applies to all cells older than the given age. |
| `maxAge[]` *Optional* | `object` <br /> |
| `maxAge[].days` *Optional* | `integer` DEPRECATED. Deprecated in favor of duration. Immutable. Number of days before applying GC policy. |
| `maxAge[].duration` *Optional* | `string` Immutable. Duration before applying GC policy. |
| `maxVersion` *Optional* | `list (object)` Immutable. NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. GC policy that applies to all versions of a cell except for the most recent. |
| `maxVersion[]` *Optional* | `object` <br /> |
| `maxVersion[].number` *Required\** | `integer` Immutable. Number of version before applying the GC policy. |
| `mode` *Optional* | `string` Immutable. NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. If multiple policies are set, you should choose between UNION OR INTERSECTION. |
| `tableRef` *Required* | `object` The name of the table. |
| `tableRef.external` *Optional* | `string` A reference to an externally managed BigtableTable resource. |
| `tableRef.name` *Optional* | `string` The name of a BigtableInstance resource. |
| `tableRef.namespace` *Optional* | `string` The namespace of a BigtableInstance resource. |

\* Field is required when parent field is specified

### Status

#### Schema

    conditions:
    - lastTransitionTime: string
      message: string
      reason: string
      status: string
      type: string
    observedGeneration: integer

| Fields ||
|---|---|
| `conditions` | `list (object)` Conditions represent the latest available observations of the object's current state. |
| `conditions[]` | `object` <br /> |
| `conditions[].lastTransitionTime` | `string` Last time the condition transitioned from one status to another. |
| `conditions[].message` | `string` Human-readable message indicating details about last transition. |
| `conditions[].reason` | `string` Unique, one-word, CamelCase reason for the condition's last transition. |
| `conditions[].status` | `string` Status is the status of the condition. Can be True, False, Unknown. |
| `conditions[].type` | `string` Type is the type of the condition. |
| `observedGeneration` | `integer` ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |

## Sample YAML(s)

### Typical Use Case

    # Copyright 2020 Google LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    apiVersion: bigtable.cnrm.cloud.google.com/v1beta1
    kind: BigtableGCPolicy
    metadata:
      name: bigtablegcpolicy-sample
    spec:
      tableRef:
        name: bigtablegcpolicy-dep
      columnFamily: family1
      instanceRef:
        name: bigtablegcpolicy-dep
      gcRules: >
        {
          "mode": "union",
          "rules": [
            {
              "max_age": "15h"
            },
            {
              "mode": "intersection",
              "rules": [
                {
                  "max_age": "2h"
                },
                {
                  "max_version": 2
                }
              ]
            }
          ]
        }
    ---
    apiVersion: bigtable.cnrm.cloud.google.com/v1beta1
    kind: BigtableInstance
    metadata:
      name: bigtablegcpolicy-dep
    spec:
      displayName: BigtableSample
      cluster:
      - clusterId: cluster
        zone: us-central1-a
        numNodes: 3
    ---
    apiVersion: bigtable.cnrm.cloud.google.com/v1beta1
    kind: BigtableTable
    metadata:
      name: bigtablegcpolicy-dep
    spec:
      columnFamily:
      - family: family1
      - family: family2
      instanceRef:
        name: bigtablegcpolicy-dep
      splitKeys:
      - a

> [!NOTE]
> **Note:** If you have any trouble with instantiating the resource, refer to [Troubleshoot Config Connector](https://docs.cloud.google.com/config-connector/docs/troubleshooting).