@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
230 lines • 8.13 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GCPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Creates a Google Cloud Bigtable GC Policy inside a family. For more information see
* [the official documentation](https://cloud.google.com/bigtable/) and
* [API](https://cloud.google.com/bigtable/docs/go/reference).
*
* > **Warning**: We don't recommend having multiple GC policies for the same column
* family as it may result in unexpected behavior.
*
* > **Note**: GC policies associated with a replicated table cannot be destroyed directly.
* Destroying a GC policy is translated into never perform garbage collection, this is
* considered relaxing from pure age-based or version-based GC policy, hence not allowed.
* The workaround is unreplicating the instance first by updating the instance to have one
* cluster.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const instance = new gcp.bigtable.Instance("instance", {
* name: "tf-instance",
* clusters: [{
* clusterId: "tf-instance-cluster",
* numNodes: 3,
* storageType: "HDD",
* }],
* });
* const table = new gcp.bigtable.Table("table", {
* name: "tf-table",
* instanceName: instance.name,
* columnFamilies: [{
* family: "name",
* }],
* });
* const policy = new gcp.bigtable.GCPolicy("policy", {
* instanceName: instance.name,
* table: table.name,
* columnFamily: "name",
* deletionPolicy: "ABANDON",
* gcRules: ` {
* \\"rules\\": [
* {
* \\"max_age\\": \\"168h\\"
* }
* ]
* }
* `,
* });
* ```
*
* Multiple conditions is also supported. `UNION` when any of its sub-policies apply (OR). `INTERSECTION` when all its sub-policies apply (AND)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const policy = new gcp.bigtable.GCPolicy("policy", {
* instanceName: instance.name,
* table: table.name,
* columnFamily: "name",
* deletionPolicy: "ABANDON",
* gcRules: ` {
* \\"mode\\": \\"union\\",
* \\"rules\\": [
* {
* \\"max_age\\": \\"168h\\"
* },
* {
* \\"max_version\\": 10
* }
* ]
* }
* `,
* });
* ```
*
* An example of more complex GC policy:
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const instance = new gcp.bigtable.Instance("instance", {
* name: "instance_name",
* clusters: [{
* clusterId: "cid",
* zone: "us-central1-b",
* }],
* instanceType: "DEVELOPMENT",
* deletionProtection: false,
* });
* const table = new gcp.bigtable.Table("table", {
* name: "your-table",
* instanceName: instance.id,
* columnFamilies: [{
* family: "cf1",
* }],
* });
* const policy = new gcp.bigtable.GCPolicy("policy", {
* instanceName: instance.id,
* table: table.name,
* columnFamily: "cf1",
* deletionPolicy: "ABANDON",
* gcRules: ` {
* \\"mode\\": \\"union\\",
* \\"rules\\": [
* {
* \\"max_age\\": \\"10h\\"
* },
* {
* \\"mode\\": \\"intersection\\",
* \\"rules\\": [
* {
* \\"max_age\\": \\"2h\\"
* },
* {
* \\"max_version\\": 2
* }
* ]
* }
* ]
* }
* `,
* });
* ```
* This is equivalent to running the following `cbt` command:
*
* ## Import
*
* This resource does not support import.
*/
class GCPolicy extends pulumi.CustomResource {
/**
* Get an existing GCPolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new GCPolicy(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:bigtable/gCPolicy:GCPolicy';
/**
* Returns true if the given object is an instance of GCPolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === GCPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["columnFamily"] = state?.columnFamily;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["gcRules"] = state?.gcRules;
resourceInputs["ignoreWarnings"] = state?.ignoreWarnings;
resourceInputs["instanceName"] = state?.instanceName;
resourceInputs["maxAge"] = state?.maxAge;
resourceInputs["maxVersions"] = state?.maxVersions;
resourceInputs["mode"] = state?.mode;
resourceInputs["project"] = state?.project;
resourceInputs["table"] = state?.table;
}
else {
const args = argsOrState;
if (args?.columnFamily === undefined && !opts.urn) {
throw new Error("Missing required property 'columnFamily'");
}
if (args?.instanceName === undefined && !opts.urn) {
throw new Error("Missing required property 'instanceName'");
}
if (args?.table === undefined && !opts.urn) {
throw new Error("Missing required property 'table'");
}
resourceInputs["columnFamily"] = args?.columnFamily;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["gcRules"] = args?.gcRules;
resourceInputs["ignoreWarnings"] = args?.ignoreWarnings;
resourceInputs["instanceName"] = args?.instanceName;
resourceInputs["maxAge"] = args?.maxAge;
resourceInputs["maxVersions"] = args?.maxVersions;
resourceInputs["mode"] = args?.mode;
resourceInputs["project"] = args?.project;
resourceInputs["table"] = args?.table;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(GCPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.GCPolicy = GCPolicy;
//# sourceMappingURL=gcpolicy.js.map