@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
155 lines • 6.19 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.Database = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Represents a SQL database inside the Cloud SQL instance, hosted in
* Google's cloud.
*
* ## Example Usage
*
* ### Sql Database Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // See versions at https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#database_version
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "my-database-instance",
* region: "us-central1",
* databaseVersion: "MYSQL_8_0",
* settings: {
* tier: "db-f1-micro",
* },
* deletionProtection: true,
* });
* const database = new gcp.sql.Database("database", {
* name: "my-database",
* instance: instance.name,
* });
* ```
* ### Sql Database Deletion Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // See versions at https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#database_version
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "my-database-instance",
* region: "us-central1",
* databaseVersion: "POSTGRES_14",
* settings: {
* tier: "db-g1-small",
* },
* deletionProtection: true,
* });
* const databaseDeletionPolicy = new gcp.sql.Database("database_deletion_policy", {
* name: "my-database",
* instance: instance.name,
* deletionPolicy: "ABANDON",
* });
* ```
*
* ## 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:sql/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}}
* $ pulumi import gcp:sql/database:Database default instances/{{instance}}/databases/{{name}}
* $ pulumi import gcp:sql/database:Database default {{project}}/{{instance}}/{{name}}
* $ pulumi import gcp:sql/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, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:sql/database:Database';
/**
* 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["charset"] = state?.charset;
resourceInputs["collation"] = state?.collation;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["instance"] = state?.instance;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["selfLink"] = state?.selfLink;
}
else {
const args = argsOrState;
if (args?.instance === undefined && !opts.urn) {
throw new Error("Missing required property 'instance'");
}
resourceInputs["charset"] = args?.charset;
resourceInputs["collation"] = args?.collation;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["instance"] = args?.instance;
resourceInputs["name"] = args?.name;
resourceInputs["project"] = args?.project;
resourceInputs["selfLink"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Database.__pulumiType, name, resourceInputs, opts);
}
}
exports.Database = Database;
//# sourceMappingURL=database.js.map