@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
211 lines • 8.6 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.BackupSchedule = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* A backup schedule for a Cloud Spanner Database.
* This resource is owned by the database it is backing up, and is deleted along with the database.
* The actual backups are not though.
*
* To get more information about BackupSchedule, see:
*
* * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.backupSchedules)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/spanner/docs/backup)
*
* > **Warning:** This resource creates a Spanner Backup Schedule on a project that already has
* a Spanner database.
* This resource is owned by the database it is backing up, and is deleted along
* with the database. The actual backups are not though.
*
* ## Example Usage
*
* ### Spanner Backup Schedule Daily Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const main = new gcp.spanner.Instance("main", {
* name: "instance-id",
* config: "regional-europe-west1",
* displayName: "main-instance",
* numNodes: 1,
* });
* const database = new gcp.spanner.Database("database", {
* instance: main.name,
* name: "database-id",
* versionRetentionPeriod: "3d",
* ddls: [
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
* ],
* deletionProtection: true,
* });
* const full_backup = new gcp.spanner.BackupSchedule("full-backup", {
* instance: main.name,
* database: database.name,
* name: "backup-schedule-id",
* retentionDuration: "31620000s",
* spec: {
* cronSpec: {
* text: "0 12 * * *",
* },
* },
* fullBackupSpec: {},
* encryptionConfig: {
* encryptionType: "USE_DATABASE_ENCRYPTION",
* },
* });
* ```
* ### Spanner Backup Schedule Daily Incremental
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const main = new gcp.spanner.Instance("main", {
* name: "instance-id",
* config: "regional-europe-west1",
* displayName: "main-instance",
* numNodes: 1,
* edition: "ENTERPRISE",
* });
* const database = new gcp.spanner.Database("database", {
* instance: main.name,
* name: "database-id",
* versionRetentionPeriod: "3d",
* ddls: [
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
* ],
* deletionProtection: true,
* });
* const incremental_backup = new gcp.spanner.BackupSchedule("incremental-backup", {
* instance: main.name,
* database: database.name,
* name: "backup-schedule-id",
* retentionDuration: "31620000s",
* spec: {
* cronSpec: {
* text: "0 12 * * *",
* },
* },
* incrementalBackupSpec: {},
* encryptionConfig: {
* encryptionType: "GOOGLE_DEFAULT_ENCRYPTION",
* },
* });
* ```
*
* ## Import
*
* BackupSchedule can be imported using any of these accepted formats:
*
* * `projects/{{project}}/instances/{{instance}}/databases/{{database}}/backupSchedules/{{name}}`
* * `{{project}}/{{instance}}/{{database}}/{{name}}`
* * `{{instance}}/{{database}}/{{name}}`
*
* When using the `pulumi import` command, BackupSchedule can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:spanner/backupSchedule:BackupSchedule default projects/{{project}}/instances/{{instance}}/databases/{{database}}/backupSchedules/{{name}}
* $ pulumi import gcp:spanner/backupSchedule:BackupSchedule default {{project}}/{{instance}}/{{database}}/{{name}}
* $ pulumi import gcp:spanner/backupSchedule:BackupSchedule default {{instance}}/{{database}}/{{name}}
* ```
*/
class BackupSchedule extends pulumi.CustomResource {
/**
* Get an existing BackupSchedule 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 BackupSchedule(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:spanner/backupSchedule:BackupSchedule';
/**
* Returns true if the given object is an instance of BackupSchedule. 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'] === BackupSchedule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["database"] = state?.database;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["encryptionConfig"] = state?.encryptionConfig;
resourceInputs["fullBackupSpec"] = state?.fullBackupSpec;
resourceInputs["incrementalBackupSpec"] = state?.incrementalBackupSpec;
resourceInputs["instance"] = state?.instance;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["retentionDuration"] = state?.retentionDuration;
resourceInputs["spec"] = state?.spec;
}
else {
const args = argsOrState;
if (args?.database === undefined && !opts.urn) {
throw new Error("Missing required property 'database'");
}
if (args?.instance === undefined && !opts.urn) {
throw new Error("Missing required property 'instance'");
}
if (args?.retentionDuration === undefined && !opts.urn) {
throw new Error("Missing required property 'retentionDuration'");
}
resourceInputs["database"] = args?.database;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["encryptionConfig"] = args?.encryptionConfig;
resourceInputs["fullBackupSpec"] = args?.fullBackupSpec;
resourceInputs["incrementalBackupSpec"] = args?.incrementalBackupSpec;
resourceInputs["instance"] = args?.instance;
resourceInputs["name"] = args?.name;
resourceInputs["project"] = args?.project;
resourceInputs["retentionDuration"] = args?.retentionDuration;
resourceInputs["spec"] = args?.spec;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BackupSchedule.__pulumiType, name, resourceInputs, opts);
}
}
exports.BackupSchedule = BackupSchedule;
//# sourceMappingURL=backupSchedule.js.map