UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

140 lines 6.03 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Database = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A Cloud Spanner Database which is hosted on a Spanner instance. * * To get more information about Database, see: * * * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases) * * How-to Guides * * [Official Documentation](https://cloud.google.com/spanner/) * * > **Warning:** On newer versions of the provider, you must explicitly set `deletion_protection=false` * (and run `pulumi up` to write the field to state) in order to destroy an instance. * It is recommended to not set this field (or set it to true) until you're ready to destroy. * On older versions, it is strongly recommended to set `lifecycle { preventDestroy = true }` * on databases in order to prevent accidental data loss. * * ## Example Usage * * ### Spanner Database Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const main = new gcp.spanner.Instance("main", { * config: "regional-europe-west1", * displayName: "main-instance", * numNodes: 1, * }); * const database = new gcp.spanner.Database("database", { * instance: main.name, * name: "my-database", * versionRetentionPeriod: "3d", * ddls: [ * "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", * "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", * ], * deletionProtection: false, * }); * ``` * * ## Import * * Database can be imported using any of these accepted formats: * * * `projects/{{project}}/instances/{{instance}}/databases/{{name}}` * * * `instances/{{instance}}/databases/{{name}}` * * * `{{project}}/{{instance}}/{{name}}` * * * `{{instance}}/{{name}}` * * When using the `pulumi import` command, Database can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:spanner/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}} * ``` * * ```sh * $ pulumi import gcp:spanner/database:Database default instances/{{instance}}/databases/{{name}} * ``` * * ```sh * $ pulumi import gcp:spanner/database:Database default {{project}}/{{instance}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:spanner/database:Database default {{instance}}/{{name}} * ``` */ class Database extends pulumi.CustomResource { /** * Get an existing Database 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 Database(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Database. 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'] === Database.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["databaseDialect"] = state ? state.databaseDialect : undefined; resourceInputs["ddls"] = state ? state.ddls : undefined; resourceInputs["deletionProtection"] = state ? state.deletionProtection : undefined; resourceInputs["enableDropProtection"] = state ? state.enableDropProtection : undefined; resourceInputs["encryptionConfig"] = state ? state.encryptionConfig : undefined; resourceInputs["instance"] = state ? state.instance : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["state"] = state ? state.state : undefined; resourceInputs["versionRetentionPeriod"] = state ? state.versionRetentionPeriod : undefined; } else { const args = argsOrState; if ((!args || args.instance === undefined) && !opts.urn) { throw new Error("Missing required property 'instance'"); } resourceInputs["databaseDialect"] = args ? args.databaseDialect : undefined; resourceInputs["ddls"] = args ? args.ddls : undefined; resourceInputs["deletionProtection"] = args ? args.deletionProtection : undefined; resourceInputs["enableDropProtection"] = args ? args.enableDropProtection : undefined; resourceInputs["encryptionConfig"] = args ? args.encryptionConfig : undefined; resourceInputs["instance"] = args ? args.instance : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["versionRetentionPeriod"] = args ? args.versionRetentionPeriod : undefined; resourceInputs["state"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Database.__pulumiType, name, resourceInputs, opts); } } exports.Database = Database; /** @internal */ Database.__pulumiType = 'gcp:spanner/database:Database'; //# sourceMappingURL=database.js.map