@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
150 lines • 5.6 kB
JavaScript
;
// *** 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");
/**
* 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}}`
*
* * `{{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}}
* ```
*
* ```sh
* $ pulumi import gcp:sql/database:Database default instances/{{instance}}/databases/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:sql/database:Database default {{project}}/{{instance}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:sql/database:Database default {{instance}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:sql/database:Database default {{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["charset"] = state ? state.charset : undefined;
resourceInputs["collation"] = state ? state.collation : undefined;
resourceInputs["deletionPolicy"] = state ? state.deletionPolicy : undefined;
resourceInputs["instance"] = state ? state.instance : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
}
else {
const args = argsOrState;
if ((!args || args.instance === undefined) && !opts.urn) {
throw new Error("Missing required property 'instance'");
}
resourceInputs["charset"] = args ? args.charset : undefined;
resourceInputs["collation"] = args ? args.collation : undefined;
resourceInputs["deletionPolicy"] = args ? args.deletionPolicy : undefined;
resourceInputs["instance"] = args ? args.instance : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["selfLink"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Database.__pulumiType, name, resourceInputs, opts);
}
}
exports.Database = Database;
/** @internal */
Database.__pulumiType = 'gcp:sql/database:Database';
//# sourceMappingURL=database.js.map