UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

250 lines • 11.6 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.GlobalCluster = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an RDS Global Cluster, which is an Aurora global database spread across multiple regions. The global database contains a single primary cluster with read-write capability, and a read-only secondary cluster that receives data from the primary cluster through high-speed replication performed by the Aurora storage subsystem. * * More information about Aurora global databases can be found in the [Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database.html#aurora-global-database-creating). * * ## Example Usage * * ### New MySQL Global Cluster * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.GlobalCluster("example", { * globalClusterIdentifier: "global-test", * engine: "aurora", * engineVersion: "5.6.mysql_aurora.1.22.2", * databaseName: "example_db", * }); * const primary = new aws.rds.Cluster("primary", { * engine: example.engine, * engineVersion: example.engineVersion, * clusterIdentifier: "test-primary-cluster", * masterUsername: "username", * masterPassword: "somepass123", * databaseName: "example_db", * globalClusterIdentifier: example.id, * dbSubnetGroupName: "default", * }); * const primaryClusterInstance = new aws.rds.ClusterInstance("primary", { * engine: example.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: example.engineVersion, * identifier: "test-primary-cluster-instance", * clusterIdentifier: primary.id, * instanceClass: aws.rds.InstanceType.R4_Large, * dbSubnetGroupName: "default", * }); * const secondary = new aws.rds.Cluster("secondary", { * engine: example.engine, * engineVersion: example.engineVersion, * clusterIdentifier: "test-secondary-cluster", * globalClusterIdentifier: example.id, * dbSubnetGroupName: "default", * }, { * dependsOn: [primaryClusterInstance], * }); * const secondaryClusterInstance = new aws.rds.ClusterInstance("secondary", { * engine: example.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: example.engineVersion, * identifier: "test-secondary-cluster-instance", * clusterIdentifier: secondary.id, * instanceClass: aws.rds.InstanceType.R4_Large, * dbSubnetGroupName: "default", * }); * ``` * * ### New PostgreSQL Global Cluster * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.GlobalCluster("example", { * globalClusterIdentifier: "global-test", * engine: "aurora-postgresql", * engineVersion: "11.9", * databaseName: "example_db", * }); * const primary = new aws.rds.Cluster("primary", { * engine: example.engine, * engineVersion: example.engineVersion, * clusterIdentifier: "test-primary-cluster", * masterUsername: "username", * masterPassword: "somepass123", * databaseName: "example_db", * globalClusterIdentifier: example.id, * dbSubnetGroupName: "default", * }); * const primaryClusterInstance = new aws.rds.ClusterInstance("primary", { * engine: example.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: example.engineVersion, * identifier: "test-primary-cluster-instance", * clusterIdentifier: primary.id, * instanceClass: aws.rds.InstanceType.R4_Large, * dbSubnetGroupName: "default", * }); * const secondary = new aws.rds.Cluster("secondary", { * engine: example.engine, * engineVersion: example.engineVersion, * clusterIdentifier: "test-secondary-cluster", * globalClusterIdentifier: example.id, * skipFinalSnapshot: true, * dbSubnetGroupName: "default", * }, { * dependsOn: [primaryClusterInstance], * }); * const secondaryClusterInstance = new aws.rds.ClusterInstance("secondary", { * engine: example.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: example.engineVersion, * identifier: "test-secondary-cluster-instance", * clusterIdentifier: secondary.id, * instanceClass: aws.rds.InstanceType.R4_Large, * dbSubnetGroupName: "default", * }); * ``` * * ### New Global Cluster From Existing DB Cluster * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.Cluster("example", {}); * const exampleGlobalCluster = new aws.rds.GlobalCluster("example", { * forceDestroy: true, * globalClusterIdentifier: "example", * sourceDbClusterIdentifier: example.arn, * }); * ``` * * ### Upgrading Engine Versions * * When you upgrade the version of an `aws.rds.GlobalCluster`, the provider will attempt to in-place upgrade the engine versions of all associated clusters. Since the `aws.rds.Cluster` resource is being updated through the `aws.rds.GlobalCluster`, you are likely to get an error (`Provider produced inconsistent final plan`). To avoid this, use the `lifecycle` `ignoreChanges` meta argument as shown below on the `aws.rds.Cluster`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.GlobalCluster("example", { * globalClusterIdentifier: "kyivkharkiv", * engine: "aurora-mysql", * engineVersion: "5.7.mysql_aurora.2.07.5", * }); * const primary = new aws.rds.Cluster("primary", { * allowMajorVersionUpgrade: true, * applyImmediately: true, * clusterIdentifier: "odessadnipro", * databaseName: "totoro", * engine: example.engine, * engineVersion: example.engineVersion, * globalClusterIdentifier: example.id, * masterPassword: "satsukimae", * masterUsername: "maesatsuki", * skipFinalSnapshot: true, * }); * const primaryClusterInstance = new aws.rds.ClusterInstance("primary", { * applyImmediately: true, * clusterIdentifier: primary.id, * engine: primary.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: primary.engineVersion, * identifier: "donetsklviv", * instanceClass: aws.rds.InstanceType.R4_Large, * }); * ``` * * ## Import * * Using `pulumi import`, import `aws_rds_global_cluster` using the RDS Global Cluster identifier. For example: * * ```sh * $ pulumi import aws:rds/globalCluster:GlobalCluster example example * ``` * Certain resource arguments, like `force_destroy`, only exist within this provider. If the argument is set in the the provider configuration on an imported resource, This provider will show a difference on the first plan after import to update the state value. This change is safe to apply immediately so the state matches the desired configuration. * * Certain resource arguments, like `source_db_cluster_identifier`, do not have an API method for reading the information after creation. If the argument is set in the Pulumi program on an imported resource, Pulumi will always show a difference. To workaround this behavior, either omit the argument from the Pulumi program or use `ignore_changes` to hide the difference. For example: */ class GlobalCluster extends pulumi.CustomResource { /** * Get an existing GlobalCluster 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 GlobalCluster(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of GlobalCluster. 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'] === GlobalCluster.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["arn"] = state?.arn; resourceInputs["databaseName"] = state?.databaseName; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["endpoint"] = state?.endpoint; resourceInputs["engine"] = state?.engine; resourceInputs["engineLifecycleSupport"] = state?.engineLifecycleSupport; resourceInputs["engineVersion"] = state?.engineVersion; resourceInputs["engineVersionActual"] = state?.engineVersionActual; resourceInputs["forceDestroy"] = state?.forceDestroy; resourceInputs["globalClusterIdentifier"] = state?.globalClusterIdentifier; resourceInputs["globalClusterMembers"] = state?.globalClusterMembers; resourceInputs["globalClusterResourceId"] = state?.globalClusterResourceId; resourceInputs["region"] = state?.region; resourceInputs["sourceDbClusterIdentifier"] = state?.sourceDbClusterIdentifier; resourceInputs["storageEncrypted"] = state?.storageEncrypted; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; } else { const args = argsOrState; if (args?.globalClusterIdentifier === undefined && !opts.urn) { throw new Error("Missing required property 'globalClusterIdentifier'"); } resourceInputs["databaseName"] = args?.databaseName; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["engine"] = args?.engine; resourceInputs["engineLifecycleSupport"] = args?.engineLifecycleSupport; resourceInputs["engineVersion"] = args?.engineVersion; resourceInputs["forceDestroy"] = args?.forceDestroy; resourceInputs["globalClusterIdentifier"] = args?.globalClusterIdentifier; resourceInputs["region"] = args?.region; resourceInputs["sourceDbClusterIdentifier"] = args?.sourceDbClusterIdentifier; resourceInputs["storageEncrypted"] = args?.storageEncrypted; resourceInputs["tags"] = args?.tags; resourceInputs["arn"] = undefined /*out*/; resourceInputs["endpoint"] = undefined /*out*/; resourceInputs["engineVersionActual"] = undefined /*out*/; resourceInputs["globalClusterMembers"] = undefined /*out*/; resourceInputs["globalClusterResourceId"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(GlobalCluster.__pulumiType, name, resourceInputs, opts); } } exports.GlobalCluster = GlobalCluster; /** @internal */ GlobalCluster.__pulumiType = 'aws:rds/globalCluster:GlobalCluster'; //# sourceMappingURL=globalCluster.js.map