@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
350 lines • 17.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.Instance = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manage RDS instance resource within HuaweiCloud.
*
* ## Example Usage
* ### create a single db instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const vpcId = config.requireObject("vpcId");
* const subnetId = config.requireObject("subnetId");
* const secgroupId = config.requireObject("secgroupId");
* const availabilityZone = config.requireObject("availabilityZone");
* const postgreSQLPassword = config.requireObject("postgreSQLPassword");
* const instance = new huaweicloud.rds.Instance("instance", {
* flavor: "rds.pg.n1.large.2",
* vpcId: vpcId,
* subnetId: subnetId,
* securityGroupId: secgroupId,
* availabilityZones: [availabilityZone],
* db: {
* type: "PostgreSQL",
* version: "12",
* password: postgreSQLPassword,
* },
* volume: {
* type: "ULTRAHIGH",
* size: 100,
* },
* backupStrategy: {
* startTime: "08:00-09:00",
* keepDays: 1,
* },
* });
* ```
* ### create a primary/standby db instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const vpcId = config.requireObject("vpcId");
* const subnetId = config.requireObject("subnetId");
* const secgroupId = config.requireObject("secgroupId");
* const availabilityZone1 = config.requireObject("availabilityZone1");
* const availabilityZone2 = config.requireObject("availabilityZone2");
* const postgreSQLPassword = config.requireObject("postgreSQLPassword");
* const instance = new huaweicloud.rds.Instance("instance", {
* flavor: "rds.pg.n1.large.2.ha",
* haReplicationMode: "async",
* vpcId: vpcId,
* subnetId: subnetId,
* securityGroupId: secgroupId,
* availabilityZones: [
* availabilityZone1,
* availabilityZone2,
* ],
* db: {
* type: "PostgreSQL",
* version: "12",
* password: postgreSQLPassword,
* },
* volume: {
* type: "ULTRAHIGH",
* size: 100,
* },
* backupStrategy: {
* startTime: "08:00-09:00",
* keepDays: 1,
* },
* });
* ```
* ### create a single db instance with encrypted volume
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const vpcId = config.requireObject("vpcId");
* const subnetId = config.requireObject("subnetId");
* const secgroupId = config.requireObject("secgroupId");
* const availabilityZone = config.requireObject("availabilityZone");
* const kmsId = config.requireObject("kmsId");
* const postgreSQLPassword = config.requireObject("postgreSQLPassword");
* const instance = new huaweicloud.rds.Instance("instance", {
* flavor: "rds.pg.n1.large.2",
* vpcId: vpcId,
* subnetId: subnetId,
* securityGroupId: secgroupId,
* availabilityZones: [availabilityZone],
* db: {
* type: "PostgreSQL",
* version: "12",
* password: postgreSQLPassword,
* },
* volume: {
* type: "ULTRAHIGH",
* size: 100,
* diskEncryptionId: kmsId,
* },
* backupStrategy: {
* startTime: "08:00-09:00",
* keepDays: 1,
* },
* });
* ```
* ### create db instance with customized parameters
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const vpcId = config.requireObject("vpcId");
* const subnetId = config.requireObject("subnetId");
* const secgroupId = config.requireObject("secgroupId");
* const availabilityZone = config.requireObject("availabilityZone");
* const postgreSQLPassword = config.requireObject("postgreSQLPassword");
* const instance = new huaweicloud.rds.Instance("instance", {
* flavor: "rds.pg.n1.large.2",
* vpcId: vpcId,
* subnetId: subnetId,
* securityGroupId: secgroupId,
* availabilityZones: [availabilityZone],
* db: {
* type: "PostgreSQL",
* version: "12",
* password: postgreSQLPassword,
* },
* volume: {
* type: "ULTRAHIGH",
* size: 100,
* },
* backupStrategy: {
* startTime: "08:00-09:00",
* keepDays: 1,
* },
* parameters: [
* {
* name: "div_precision_increment",
* value: "12",
* },
* {
* name: "connect_timeout",
* value: "13",
* },
* ],
* });
* ```
*
* ## Import
*
* RDS instance can be imported using the `id`, e.g. bash
*
* ```sh
* $ pulumi import huaweicloud:Rds/instance:Instance instance_1 <id>
* ```
*
* Note that the imported state may not be identical to your resource definition, due to some attributes missing from the API response, security or some other reason. The missing attributes include`db`, `restore`,`param_group_id`, `power_action`, `availability_zone`, `read_write_permissions`, `rotate_day`, `secret_id`, `secret_name`, `secret_version`, `dss_pool_id`, `lower_case_table_names`, `slow_log_show_original_status`, `charging_mode`, `period_unit`, `period`, `auto_renew`, `auto_pay`. It is generally recommended running `terraform plan` after importing a RDS instance. You can then decide if changes should be applied to the instance, or the resource definition should be updated to align with the instance. Also, you can ignore changes as below. hcl resource "huaweicloud_rds_instance" "instance_1" {
*
* ...
*
* lifecycle {
*
* ignore_changes = [
*
* "db", "restore", "param_group_id", "power_action", "availability_zone", "read_write_permissions", "rotate_day",
*
* "secret_id", "secret_name", "secret_version", "dss_pool_id", "lower_case_table_names", "slow_log_show_original_status",
*
* "charging_mode", "period_unit", "period", "auto_renew", "auto_pay",
*
* ]
*
* } }
*/
class Instance extends pulumi.CustomResource {
/**
* Get an existing Instance 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 Instance(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Instance. 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'] === Instance.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["autoPay"] = state ? state.autoPay : undefined;
resourceInputs["autoRenew"] = state ? state.autoRenew : undefined;
resourceInputs["availabilityZones"] = state ? state.availabilityZones : undefined;
resourceInputs["backupStrategy"] = state ? state.backupStrategy : undefined;
resourceInputs["binlogRetentionHours"] = state ? state.binlogRetentionHours : undefined;
resourceInputs["chargingMode"] = state ? state.chargingMode : undefined;
resourceInputs["collation"] = state ? state.collation : undefined;
resourceInputs["created"] = state ? state.created : undefined;
resourceInputs["db"] = state ? state.db : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["dssPoolId"] = state ? state.dssPoolId : undefined;
resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined;
resourceInputs["fixedIp"] = state ? state.fixedIp : undefined;
resourceInputs["flavor"] = state ? state.flavor : undefined;
resourceInputs["haReplicationMode"] = state ? state.haReplicationMode : undefined;
resourceInputs["lowerCaseTableNames"] = state ? state.lowerCaseTableNames : undefined;
resourceInputs["maintainBegin"] = state ? state.maintainBegin : undefined;
resourceInputs["maintainEnd"] = state ? state.maintainEnd : undefined;
resourceInputs["minorVersionAutoUpgradeEnabled"] = state ? state.minorVersionAutoUpgradeEnabled : undefined;
resourceInputs["msdtcHosts"] = state ? state.msdtcHosts : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["nodes"] = state ? state.nodes : undefined;
resourceInputs["paramGroupId"] = state ? state.paramGroupId : undefined;
resourceInputs["parameters"] = state ? state.parameters : undefined;
resourceInputs["period"] = state ? state.period : undefined;
resourceInputs["periodUnit"] = state ? state.periodUnit : undefined;
resourceInputs["powerAction"] = state ? state.powerAction : undefined;
resourceInputs["privateDnsNamePrefix"] = state ? state.privateDnsNamePrefix : undefined;
resourceInputs["privateDnsNames"] = state ? state.privateDnsNames : undefined;
resourceInputs["privateIps"] = state ? state.privateIps : undefined;
resourceInputs["publicIps"] = state ? state.publicIps : undefined;
resourceInputs["readWritePermissions"] = state ? state.readWritePermissions : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["restore"] = state ? state.restore : undefined;
resourceInputs["rotateDay"] = state ? state.rotateDay : undefined;
resourceInputs["secondsLevelMonitoringEnabled"] = state ? state.secondsLevelMonitoringEnabled : undefined;
resourceInputs["secondsLevelMonitoringInterval"] = state ? state.secondsLevelMonitoringInterval : undefined;
resourceInputs["secretId"] = state ? state.secretId : undefined;
resourceInputs["secretName"] = state ? state.secretName : undefined;
resourceInputs["secretVersion"] = state ? state.secretVersion : undefined;
resourceInputs["securityGroupId"] = state ? state.securityGroupId : undefined;
resourceInputs["slowLogShowOriginalStatus"] = state ? state.slowLogShowOriginalStatus : undefined;
resourceInputs["sslEnable"] = state ? state.sslEnable : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["subnetId"] = state ? state.subnetId : undefined;
resourceInputs["switchStrategy"] = state ? state.switchStrategy : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tdeEnabled"] = state ? state.tdeEnabled : undefined;
resourceInputs["timeZone"] = state ? state.timeZone : undefined;
resourceInputs["volume"] = state ? state.volume : undefined;
resourceInputs["vpcId"] = state ? state.vpcId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.availabilityZones === undefined) && !opts.urn) {
throw new Error("Missing required property 'availabilityZones'");
}
if ((!args || args.db === undefined) && !opts.urn) {
throw new Error("Missing required property 'db'");
}
if ((!args || args.flavor === undefined) && !opts.urn) {
throw new Error("Missing required property 'flavor'");
}
if ((!args || args.securityGroupId === undefined) && !opts.urn) {
throw new Error("Missing required property 'securityGroupId'");
}
if ((!args || args.subnetId === undefined) && !opts.urn) {
throw new Error("Missing required property 'subnetId'");
}
if ((!args || args.volume === undefined) && !opts.urn) {
throw new Error("Missing required property 'volume'");
}
if ((!args || args.vpcId === undefined) && !opts.urn) {
throw new Error("Missing required property 'vpcId'");
}
resourceInputs["autoPay"] = args ? args.autoPay : undefined;
resourceInputs["autoRenew"] = args ? args.autoRenew : undefined;
resourceInputs["availabilityZones"] = args ? args.availabilityZones : undefined;
resourceInputs["backupStrategy"] = args ? args.backupStrategy : undefined;
resourceInputs["binlogRetentionHours"] = args ? args.binlogRetentionHours : undefined;
resourceInputs["chargingMode"] = args ? args.chargingMode : undefined;
resourceInputs["collation"] = args ? args.collation : undefined;
resourceInputs["db"] = args ? args.db : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["dssPoolId"] = args ? args.dssPoolId : undefined;
resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined;
resourceInputs["fixedIp"] = args ? args.fixedIp : undefined;
resourceInputs["flavor"] = args ? args.flavor : undefined;
resourceInputs["haReplicationMode"] = args ? args.haReplicationMode : undefined;
resourceInputs["lowerCaseTableNames"] = args ? args.lowerCaseTableNames : undefined;
resourceInputs["maintainBegin"] = args ? args.maintainBegin : undefined;
resourceInputs["maintainEnd"] = args ? args.maintainEnd : undefined;
resourceInputs["minorVersionAutoUpgradeEnabled"] = args ? args.minorVersionAutoUpgradeEnabled : undefined;
resourceInputs["msdtcHosts"] = args ? args.msdtcHosts : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["paramGroupId"] = args ? args.paramGroupId : undefined;
resourceInputs["parameters"] = args ? args.parameters : undefined;
resourceInputs["period"] = args ? args.period : undefined;
resourceInputs["periodUnit"] = args ? args.periodUnit : undefined;
resourceInputs["powerAction"] = args ? args.powerAction : undefined;
resourceInputs["privateDnsNamePrefix"] = args ? args.privateDnsNamePrefix : undefined;
resourceInputs["readWritePermissions"] = args ? args.readWritePermissions : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["restore"] = args ? args.restore : undefined;
resourceInputs["rotateDay"] = args ? args.rotateDay : undefined;
resourceInputs["secondsLevelMonitoringEnabled"] = args ? args.secondsLevelMonitoringEnabled : undefined;
resourceInputs["secondsLevelMonitoringInterval"] = args ? args.secondsLevelMonitoringInterval : undefined;
resourceInputs["secretId"] = args ? args.secretId : undefined;
resourceInputs["secretName"] = args ? args.secretName : undefined;
resourceInputs["secretVersion"] = args ? args.secretVersion : undefined;
resourceInputs["securityGroupId"] = args ? args.securityGroupId : undefined;
resourceInputs["slowLogShowOriginalStatus"] = args ? args.slowLogShowOriginalStatus : undefined;
resourceInputs["sslEnable"] = args ? args.sslEnable : undefined;
resourceInputs["subnetId"] = args ? args.subnetId : undefined;
resourceInputs["switchStrategy"] = args ? args.switchStrategy : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["tdeEnabled"] = args ? args.tdeEnabled : undefined;
resourceInputs["timeZone"] = args ? args.timeZone : undefined;
resourceInputs["volume"] = args ? args.volume : undefined;
resourceInputs["vpcId"] = args ? args.vpcId : undefined;
resourceInputs["created"] = undefined /*out*/;
resourceInputs["nodes"] = undefined /*out*/;
resourceInputs["privateDnsNames"] = undefined /*out*/;
resourceInputs["privateIps"] = undefined /*out*/;
resourceInputs["publicIps"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Instance.__pulumiType, name, resourceInputs, opts);
}
}
exports.Instance = Instance;
/** @internal */
Instance.__pulumiType = 'huaweicloud:Rds/instance:Instance';
//# sourceMappingURL=instance.js.map