UNPKG

@pulumi/gcp

Version:

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

454 lines • 18.8 kB
"use strict"; // *** 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.Cluster = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A managed alloydb cluster. * * To get more information about Cluster, see: * * * [API documentation](https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.clusters/create) * * How-to Guides * * [AlloyDB](https://cloud.google.com/alloydb/docs/) * * > **Note:** Users can promote a secondary cluster to a primary cluster with the help of `clusterType`. * To promote, users have to set the `clusterType` property as `PRIMARY` and remove the `secondaryConfig` field from cluster configuration. * See Example. * * Switchover is supported in terraform by refreshing the state of the terraform configurations. * The switchover operation still needs to be called outside of terraform. * After the switchover operation is completed successfully: * 1. Refresh the state of the AlloyDB resources by running `pulumi up -refresh-only --auto-approve` . * 2. Manually update the terraform configuration file(s) to match the actual state of the resources by modifying the `clusterType` and `secondaryConfig` fields. * 3. Verify the sync of terraform state by running `pulumi preview` and ensure that the infrastructure matches the configuration and no changes are required. * * > **Note:** All arguments marked as write-only values will not be stored in the state: `initial_user.password_wo`. * Read more about Write-only Arguments. * * ## Example Usage * * ### Alloydb Cluster Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-cluster"}); * const _default = new gcp.alloydb.Cluster("default", { * clusterId: "alloydb-cluster", * location: "us-central1", * networkConfig: { * network: defaultNetwork.id, * }, * deletionProtection: false, * }); * const project = gcp.organizations.getProject({}); * ``` * ### Alloydb Cluster Before Upgrade * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = gcp.compute.getNetwork({ * name: "alloydb-network", * }); * const defaultCluster = new gcp.alloydb.Cluster("default", { * clusterId: "alloydb-cluster", * location: "us-central1", * networkConfig: { * network: _default.then(_default => _default.id), * }, * databaseVersion: "POSTGRES_14", * initialUser: { * password: "alloydb-cluster", * }, * deletionProtection: false, * }); * const defaultInstance = new gcp.alloydb.Instance("default", { * cluster: defaultCluster.name, * instanceId: "alloydb-instance", * instanceType: "PRIMARY", * machineConfig: { * cpuCount: 2, * }, * }); * ``` * ### Alloydb Cluster After Upgrade * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = gcp.compute.getNetwork({ * name: "alloydb-network", * }); * const defaultCluster = new gcp.alloydb.Cluster("default", { * clusterId: "alloydb-cluster", * location: "us-central1", * networkConfig: { * network: _default.then(_default => _default.id), * }, * databaseVersion: "POSTGRES_15", * initialUser: { * password: "alloydb-cluster", * }, * deletionProtection: false, * }); * const defaultInstance = new gcp.alloydb.Instance("default", { * cluster: defaultCluster.name, * instanceId: "alloydb-instance", * instanceType: "PRIMARY", * machineConfig: { * cpuCount: 2, * }, * }); * ``` * ### Alloydb Cluster Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.Network("default", {name: "alloydb-cluster-full"}); * const full = new gcp.alloydb.Cluster("full", { * clusterId: "alloydb-cluster-full", * location: "us-central1", * networkConfig: { * network: _default.id, * }, * databaseVersion: "POSTGRES_15", * initialUser: { * user: "alloydb-cluster-full", * password: "alloydb-cluster-full", * }, * continuousBackupConfig: { * enabled: true, * recoveryWindowDays: 14, * }, * automatedBackupPolicy: { * location: "us-central1", * backupWindow: "1800s", * enabled: true, * weeklySchedule: { * daysOfWeeks: ["MONDAY"], * startTimes: [{ * hours: 23, * minutes: 0, * seconds: 0, * nanos: 0, * }], * }, * quantityBasedRetention: { * count: 1, * }, * labels: { * test: "alloydb-cluster-full", * }, * }, * labels: { * test: "alloydb-cluster-full", * }, * deletionProtection: false, * }); * const project = gcp.organizations.getProject({}); * ``` * ### Alloydb Cluster Restore * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = gcp.compute.getNetwork({ * name: "alloydb-network", * }); * const source = new gcp.alloydb.Cluster("source", { * clusterId: "alloydb-source-cluster", * location: "us-central1", * network: _default.then(_default => _default.id), * initialUser: { * password: "alloydb-source-cluster", * }, * deletionProtection: false, * }); * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", { * name: "alloydb-source-cluster", * addressType: "INTERNAL", * purpose: "VPC_PEERING", * prefixLength: 16, * network: _default.then(_default => _default.id), * }); * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", { * network: _default.then(_default => _default.id), * service: "servicenetworking.googleapis.com", * reservedPeeringRanges: [privateIpAlloc.name], * }); * const sourceInstance = new gcp.alloydb.Instance("source", { * cluster: source.name, * instanceId: "alloydb-instance", * instanceType: "PRIMARY", * machineConfig: { * cpuCount: 2, * }, * }, { * dependsOn: [vpcConnection], * }); * const sourceBackup = new gcp.alloydb.Backup("source", { * backupId: "alloydb-backup", * location: "us-central1", * clusterName: source.name, * }, { * dependsOn: [sourceInstance], * }); * const restoredFromBackup = new gcp.alloydb.Cluster("restored_from_backup", { * clusterId: "alloydb-backup-restored", * location: "us-central1", * networkConfig: { * network: _default.then(_default => _default.id), * }, * restoreBackupSource: { * backupName: sourceBackup.name, * }, * deletionProtection: false, * }); * const restoredViaPitr = new gcp.alloydb.Cluster("restored_via_pitr", { * clusterId: "alloydb-pitr-restored", * location: "us-central1", * networkConfig: { * network: _default.then(_default => _default.id), * }, * restoreContinuousBackupSource: { * cluster: source.name, * pointInTime: "2023-08-03T19:19:00.094Z", * }, * deletionProtection: false, * }); * const project = gcp.organizations.getProject({}); * ``` * ### Alloydb Secondary Cluster Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.Network("default", {name: "alloydb-secondary-cluster"}); * const primary = new gcp.alloydb.Cluster("primary", { * clusterId: "alloydb-primary-cluster", * location: "us-central1", * networkConfig: { * network: _default.id, * }, * deletionProtection: false, * }); * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", { * name: "alloydb-secondary-cluster", * addressType: "INTERNAL", * purpose: "VPC_PEERING", * prefixLength: 16, * network: _default.id, * }); * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", { * network: _default.id, * service: "servicenetworking.googleapis.com", * reservedPeeringRanges: [privateIpAlloc.name], * }); * const primaryInstance = new gcp.alloydb.Instance("primary", { * cluster: primary.name, * instanceId: "alloydb-primary-instance", * instanceType: "PRIMARY", * machineConfig: { * cpuCount: 2, * }, * }, { * dependsOn: [vpcConnection], * }); * const secondary = new gcp.alloydb.Cluster("secondary", { * clusterId: "alloydb-secondary-cluster", * location: "us-east1", * networkConfig: { * network: _default.id, * }, * clusterType: "SECONDARY", * continuousBackupConfig: { * enabled: false, * }, * secondaryConfig: { * primaryClusterName: primary.name, * }, * deletionProtection: false, * }, { * dependsOn: [primaryInstance], * }); * const project = gcp.organizations.getProject({}); * ``` * * ## Import * * Cluster can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}}` * * `{{project}}/{{location}}/{{cluster_id}}` * * `{{location}}/{{cluster_id}}` * * `{{cluster_id}}` * * When using the `pulumi import` command, Cluster can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:alloydb/cluster:Cluster default projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}} * $ pulumi import gcp:alloydb/cluster:Cluster default {{project}}/{{location}}/{{cluster_id}} * $ pulumi import gcp:alloydb/cluster:Cluster default {{location}}/{{cluster_id}} * $ pulumi import gcp:alloydb/cluster:Cluster default {{cluster_id}} * ``` */ class Cluster extends pulumi.CustomResource { /** * Get an existing Cluster 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 Cluster(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:alloydb/cluster:Cluster'; /** * Returns true if the given object is an instance of Cluster. 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'] === Cluster.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["annotations"] = state?.annotations; resourceInputs["automatedBackupPolicy"] = state?.automatedBackupPolicy; resourceInputs["backupSources"] = state?.backupSources; resourceInputs["backupdrBackupSources"] = state?.backupdrBackupSources; resourceInputs["clusterId"] = state?.clusterId; resourceInputs["clusterType"] = state?.clusterType; resourceInputs["continuousBackupConfig"] = state?.continuousBackupConfig; resourceInputs["continuousBackupInfos"] = state?.continuousBackupInfos; resourceInputs["databaseVersion"] = state?.databaseVersion; resourceInputs["dataplexConfig"] = state?.dataplexConfig; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["displayName"] = state?.displayName; resourceInputs["effectiveAnnotations"] = state?.effectiveAnnotations; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["encryptionConfig"] = state?.encryptionConfig; resourceInputs["encryptionInfos"] = state?.encryptionInfos; resourceInputs["etag"] = state?.etag; resourceInputs["initialUser"] = state?.initialUser; resourceInputs["labels"] = state?.labels; resourceInputs["location"] = state?.location; resourceInputs["maintenanceUpdatePolicy"] = state?.maintenanceUpdatePolicy; resourceInputs["migrationSources"] = state?.migrationSources; resourceInputs["name"] = state?.name; resourceInputs["networkConfig"] = state?.networkConfig; resourceInputs["project"] = state?.project; resourceInputs["pscConfig"] = state?.pscConfig; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["reconciling"] = state?.reconciling; resourceInputs["restoreBackupSource"] = state?.restoreBackupSource; resourceInputs["restoreBackupdrBackupSource"] = state?.restoreBackupdrBackupSource; resourceInputs["restoreBackupdrPitrSource"] = state?.restoreBackupdrPitrSource; resourceInputs["restoreContinuousBackupSource"] = state?.restoreContinuousBackupSource; resourceInputs["secondaryConfig"] = state?.secondaryConfig; resourceInputs["skipAwaitMajorVersionUpgrade"] = state?.skipAwaitMajorVersionUpgrade; resourceInputs["state"] = state?.state; resourceInputs["subscriptionType"] = state?.subscriptionType; resourceInputs["trialMetadatas"] = state?.trialMetadatas; resourceInputs["uid"] = state?.uid; } else { const args = argsOrState; if (args?.clusterId === undefined && !opts.urn) { throw new Error("Missing required property 'clusterId'"); } if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } resourceInputs["annotations"] = args?.annotations; resourceInputs["automatedBackupPolicy"] = args?.automatedBackupPolicy; resourceInputs["clusterId"] = args?.clusterId; resourceInputs["clusterType"] = args?.clusterType; resourceInputs["continuousBackupConfig"] = args?.continuousBackupConfig; resourceInputs["databaseVersion"] = args?.databaseVersion; resourceInputs["dataplexConfig"] = args?.dataplexConfig; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["displayName"] = args?.displayName; resourceInputs["encryptionConfig"] = args?.encryptionConfig; resourceInputs["etag"] = args?.etag; resourceInputs["initialUser"] = args?.initialUser; resourceInputs["labels"] = args?.labels; resourceInputs["location"] = args?.location; resourceInputs["maintenanceUpdatePolicy"] = args?.maintenanceUpdatePolicy; resourceInputs["networkConfig"] = args?.networkConfig; resourceInputs["project"] = args?.project; resourceInputs["pscConfig"] = args?.pscConfig; resourceInputs["restoreBackupSource"] = args?.restoreBackupSource; resourceInputs["restoreBackupdrBackupSource"] = args?.restoreBackupdrBackupSource; resourceInputs["restoreBackupdrPitrSource"] = args?.restoreBackupdrPitrSource; resourceInputs["restoreContinuousBackupSource"] = args?.restoreContinuousBackupSource; resourceInputs["secondaryConfig"] = args?.secondaryConfig; resourceInputs["skipAwaitMajorVersionUpgrade"] = args?.skipAwaitMajorVersionUpgrade; resourceInputs["subscriptionType"] = args?.subscriptionType; resourceInputs["backupSources"] = undefined /*out*/; resourceInputs["backupdrBackupSources"] = undefined /*out*/; resourceInputs["continuousBackupInfos"] = undefined /*out*/; resourceInputs["effectiveAnnotations"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["encryptionInfos"] = undefined /*out*/; resourceInputs["migrationSources"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["reconciling"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["trialMetadatas"] = undefined /*out*/; resourceInputs["uid"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Cluster.__pulumiType, name, resourceInputs, opts); } } exports.Cluster = Cluster; //# sourceMappingURL=cluster.js.map