UNPKG

@pulumi/aws

Version:

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

412 lines • 25.4 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.Cluster = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a [RDS Aurora Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_Aurora.html) or a [RDS Multi-AZ DB Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/multi-az-db-clusters-concepts.html). To manage cluster instances that inherit configuration from the cluster (when not running the cluster in `serverless` engine mode), see the `aws.rds.ClusterInstance` resource. To manage non-Aurora DB instances (e.g., MySQL, PostgreSQL, SQL Server, etc.), see the `aws.rds.Instance` resource. * * For information on the difference between the available Aurora MySQL engines see [Comparison between Aurora MySQL 1 and Aurora MySQL 2](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AuroraMySQL.Updates.20180206.html) in the Amazon RDS User Guide. * * Changes to an RDS Cluster can occur when you manually change a parameter, such as `port`, and are reflected in the next maintenance window. Because of this, this provider may report a difference in its planning phase because a modification has not yet taken place. You can use the `applyImmediately` flag to instruct the service to apply the change immediately (see documentation below). * * > **Note:** Multi-AZ DB clusters are supported only for the MySQL and PostgreSQL DB engines. * * > **Note:** `caCertificateIdentifier` is only supported for Multi-AZ DB clusters. * * > **Note:** using `applyImmediately` can result in a brief downtime as the server reboots. See the AWS Docs on [RDS Maintenance](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html) for more information. * * > **Note:** All arguments including the username and password will be stored in the raw state as plain-text. * **NOTE on RDS Clusters and RDS Cluster Role Associations:** Pulumi provides both a standalone RDS Cluster Role Association - (an association between an RDS Cluster and a single IAM Role) and an RDS Cluster resource with `iamRoles` attributes. Use one resource or the other to associate IAM Roles and RDS Clusters. Not doing so will cause a conflict of associations and will result in the association being overwritten. * * ## Example Usage * * ### Aurora MySQL 2.x (MySQL 5.7) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const _default = new aws.rds.Cluster("default", { * clusterIdentifier: "aurora-cluster-demo", * engine: aws.rds.EngineType.AuroraMysql, * engineVersion: "5.7.mysql_aurora.2.03.2", * availabilityZones: [ * "us-west-2a", * "us-west-2b", * "us-west-2c", * ], * databaseName: "mydb", * masterUsername: "foo", * masterPassword: "must_be_eight_characters", * backupRetentionPeriod: 5, * preferredBackupWindow: "07:00-09:00", * }); * ``` * * ### Aurora MySQL 1.x (MySQL 5.6) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const _default = new aws.rds.Cluster("default", { * clusterIdentifier: "aurora-cluster-demo", * availabilityZones: [ * "us-west-2a", * "us-west-2b", * "us-west-2c", * ], * databaseName: "mydb", * masterUsername: "foo", * masterPassword: "must_be_eight_characters", * backupRetentionPeriod: 5, * preferredBackupWindow: "07:00-09:00", * }); * ``` * * ### Aurora with PostgreSQL engine * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const postgresql = new aws.rds.Cluster("postgresql", { * clusterIdentifier: "aurora-cluster-demo", * engine: aws.rds.EngineType.AuroraPostgresql, * availabilityZones: [ * "us-west-2a", * "us-west-2b", * "us-west-2c", * ], * databaseName: "mydb", * masterUsername: "foo", * masterPassword: "must_be_eight_characters", * backupRetentionPeriod: 5, * preferredBackupWindow: "07:00-09:00", * }); * ``` * * ### RDS Multi-AZ Cluster * * > More information about RDS Multi-AZ Clusters can be found in the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/multi-az-db-clusters-concepts.html). * * To create a Multi-AZ RDS cluster, you must additionally specify the `engine`, `storageType`, `allocatedStorage`, `iops` and `dbClusterInstanceClass` attributes. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.Cluster("example", { * clusterIdentifier: "example", * availabilityZones: [ * "us-west-2a", * "us-west-2b", * "us-west-2c", * ], * engine: aws.rds.EngineType.Mysql, * dbClusterInstanceClass: "db.r6gd.xlarge", * storageType: "io1", * allocatedStorage: 100, * iops: 1000, * masterUsername: "test", * masterPassword: "mustbeeightcharaters", * }); * ``` * * ### RDS Serverless v2 Cluster * * > More information about RDS Serverless v2 Clusters can be found in the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2.html). * * > **Note:** Unlike Serverless v1, in Serverless v2 the `storageEncrypted` value is set to `false` by default. * This is because Serverless v1 uses the `serverless` `engineMode`, but Serverless v2 uses the `provisioned` `engineMode`. * * To create a Serverless v2 RDS cluster, you must additionally specify the `engineMode` and `serverlessv2ScalingConfiguration` attributes. An `aws.rds.ClusterInstance` resource must also be added to the cluster with the `instanceClass` attribute specified. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.Cluster("example", { * clusterIdentifier: "example", * engine: aws.rds.EngineType.AuroraPostgresql, * engineMode: aws.rds.EngineMode.Provisioned, * engineVersion: "13.6", * databaseName: "test", * masterUsername: "test", * masterPassword: "must_be_eight_characters", * storageEncrypted: true, * serverlessv2ScalingConfiguration: { * maxCapacity: 1, * minCapacity: 0, * secondsUntilAutoPause: 3600, * }, * }); * const exampleClusterInstance = new aws.rds.ClusterInstance("example", { * clusterIdentifier: example.id, * instanceClass: "db.serverless", * engine: example.engine.apply((x) => aws.rds.EngineType[x]), * engineVersion: example.engineVersion, * }); * ``` * * ### RDS/Aurora Managed Master Passwords via Secrets Manager, default KMS Key * * > More information about RDS/Aurora Aurora integrates with Secrets Manager to manage master user passwords for your DB clusters can be found in the [RDS User Guide](https://aws.amazon.com/about-aws/whats-new/2022/12/amazon-rds-integration-aws-secrets-manager/) and [Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-secrets-manager.html). * * You can specify the `manageMasterUserPassword` attribute to enable managing the master password with Secrets Manager. You can also update an existing cluster to use Secrets Manager by specify the `manageMasterUserPassword` attribute and removing the `masterPassword` attribute (removal is required). * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.rds.Cluster("test", { * clusterIdentifier: "example", * databaseName: "test", * manageMasterUserPassword: true, * masterUsername: "test", * }); * ``` * * ### RDS/Aurora Managed Master Passwords via Secrets Manager, specific KMS Key * * > More information about RDS/Aurora Aurora integrates with Secrets Manager to manage master user passwords for your DB clusters can be found in the [RDS User Guide](https://aws.amazon.com/about-aws/whats-new/2022/12/amazon-rds-integration-aws-secrets-manager/) and [Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-secrets-manager.html). * * You can specify the `masterUserSecretKmsKeyId` attribute to specify a specific KMS Key. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.kms.Key("example", {description: "Example KMS Key"}); * const test = new aws.rds.Cluster("test", { * clusterIdentifier: "example", * databaseName: "test", * manageMasterUserPassword: true, * masterUsername: "test", * masterUserSecretKmsKeyId: example.keyId, * }); * ``` * * ### Global Cluster Restored From Snapshot * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.rds.getClusterSnapshot({ * dbClusterIdentifier: "example-original-cluster", * mostRecent: true, * }); * const exampleCluster = new aws.rds.Cluster("example", { * engine: aws.rds.EngineType.Aurora, * engineVersion: "5.6.mysql_aurora.1.22.4", * clusterIdentifier: "example", * snapshotIdentifier: example.then(example => example.id), * }); * const exampleGlobalCluster = new aws.rds.GlobalCluster("example", { * globalClusterIdentifier: "example", * sourceDbClusterIdentifier: exampleCluster.arn, * forceDestroy: true, * }); * ``` * * ## Import * * Using `pulumi import`, import RDS Clusters using the `cluster_identifier`. For example: * * ```sh * $ pulumi import aws:rds/cluster:Cluster aurora_cluster aurora-prod-cluster * ``` */ 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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["allocatedStorage"] = state ? state.allocatedStorage : undefined; resourceInputs["allowMajorVersionUpgrade"] = state ? state.allowMajorVersionUpgrade : undefined; resourceInputs["applyImmediately"] = state ? state.applyImmediately : undefined; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["availabilityZones"] = state ? state.availabilityZones : undefined; resourceInputs["backtrackWindow"] = state ? state.backtrackWindow : undefined; resourceInputs["backupRetentionPeriod"] = state ? state.backupRetentionPeriod : undefined; resourceInputs["caCertificateIdentifier"] = state ? state.caCertificateIdentifier : undefined; resourceInputs["caCertificateValidTill"] = state ? state.caCertificateValidTill : undefined; resourceInputs["clusterIdentifier"] = state ? state.clusterIdentifier : undefined; resourceInputs["clusterIdentifierPrefix"] = state ? state.clusterIdentifierPrefix : undefined; resourceInputs["clusterMembers"] = state ? state.clusterMembers : undefined; resourceInputs["clusterResourceId"] = state ? state.clusterResourceId : undefined; resourceInputs["clusterScalabilityType"] = state ? state.clusterScalabilityType : undefined; resourceInputs["copyTagsToSnapshot"] = state ? state.copyTagsToSnapshot : undefined; resourceInputs["databaseInsightsMode"] = state ? state.databaseInsightsMode : undefined; resourceInputs["databaseName"] = state ? state.databaseName : undefined; resourceInputs["dbClusterInstanceClass"] = state ? state.dbClusterInstanceClass : undefined; resourceInputs["dbClusterParameterGroupName"] = state ? state.dbClusterParameterGroupName : undefined; resourceInputs["dbInstanceParameterGroupName"] = state ? state.dbInstanceParameterGroupName : undefined; resourceInputs["dbSubnetGroupName"] = state ? state.dbSubnetGroupName : undefined; resourceInputs["dbSystemId"] = state ? state.dbSystemId : undefined; resourceInputs["deleteAutomatedBackups"] = state ? state.deleteAutomatedBackups : undefined; resourceInputs["deletionProtection"] = state ? state.deletionProtection : undefined; resourceInputs["domain"] = state ? state.domain : undefined; resourceInputs["domainIamRoleName"] = state ? state.domainIamRoleName : undefined; resourceInputs["enableGlobalWriteForwarding"] = state ? state.enableGlobalWriteForwarding : undefined; resourceInputs["enableHttpEndpoint"] = state ? state.enableHttpEndpoint : undefined; resourceInputs["enableLocalWriteForwarding"] = state ? state.enableLocalWriteForwarding : undefined; resourceInputs["enabledCloudwatchLogsExports"] = state ? state.enabledCloudwatchLogsExports : undefined; resourceInputs["endpoint"] = state ? state.endpoint : undefined; resourceInputs["engine"] = state ? state.engine : undefined; resourceInputs["engineLifecycleSupport"] = state ? state.engineLifecycleSupport : undefined; resourceInputs["engineMode"] = state ? state.engineMode : undefined; resourceInputs["engineVersion"] = state ? state.engineVersion : undefined; resourceInputs["engineVersionActual"] = state ? state.engineVersionActual : undefined; resourceInputs["finalSnapshotIdentifier"] = state ? state.finalSnapshotIdentifier : undefined; resourceInputs["globalClusterIdentifier"] = state ? state.globalClusterIdentifier : undefined; resourceInputs["hostedZoneId"] = state ? state.hostedZoneId : undefined; resourceInputs["iamDatabaseAuthenticationEnabled"] = state ? state.iamDatabaseAuthenticationEnabled : undefined; resourceInputs["iamRoles"] = state ? state.iamRoles : undefined; resourceInputs["iops"] = state ? state.iops : undefined; resourceInputs["kmsKeyId"] = state ? state.kmsKeyId : undefined; resourceInputs["manageMasterUserPassword"] = state ? state.manageMasterUserPassword : undefined; resourceInputs["masterPassword"] = state ? state.masterPassword : undefined; resourceInputs["masterUserSecretKmsKeyId"] = state ? state.masterUserSecretKmsKeyId : undefined; resourceInputs["masterUserSecrets"] = state ? state.masterUserSecrets : undefined; resourceInputs["masterUsername"] = state ? state.masterUsername : undefined; resourceInputs["monitoringInterval"] = state ? state.monitoringInterval : undefined; resourceInputs["monitoringRoleArn"] = state ? state.monitoringRoleArn : undefined; resourceInputs["networkType"] = state ? state.networkType : undefined; resourceInputs["performanceInsightsEnabled"] = state ? state.performanceInsightsEnabled : undefined; resourceInputs["performanceInsightsKmsKeyId"] = state ? state.performanceInsightsKmsKeyId : undefined; resourceInputs["performanceInsightsRetentionPeriod"] = state ? state.performanceInsightsRetentionPeriod : undefined; resourceInputs["port"] = state ? state.port : undefined; resourceInputs["preferredBackupWindow"] = state ? state.preferredBackupWindow : undefined; resourceInputs["preferredMaintenanceWindow"] = state ? state.preferredMaintenanceWindow : undefined; resourceInputs["readerEndpoint"] = state ? state.readerEndpoint : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["replicationSourceIdentifier"] = state ? state.replicationSourceIdentifier : undefined; resourceInputs["restoreToPointInTime"] = state ? state.restoreToPointInTime : undefined; resourceInputs["s3Import"] = state ? state.s3Import : undefined; resourceInputs["scalingConfiguration"] = state ? state.scalingConfiguration : undefined; resourceInputs["serverlessv2ScalingConfiguration"] = state ? state.serverlessv2ScalingConfiguration : undefined; resourceInputs["skipFinalSnapshot"] = state ? state.skipFinalSnapshot : undefined; resourceInputs["snapshotIdentifier"] = state ? state.snapshotIdentifier : undefined; resourceInputs["sourceRegion"] = state ? state.sourceRegion : undefined; resourceInputs["storageEncrypted"] = state ? state.storageEncrypted : undefined; resourceInputs["storageType"] = state ? state.storageType : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["vpcSecurityGroupIds"] = state ? state.vpcSecurityGroupIds : undefined; } else { const args = argsOrState; if ((!args || args.engine === undefined) && !opts.urn) { throw new Error("Missing required property 'engine'"); } resourceInputs["allocatedStorage"] = args ? args.allocatedStorage : undefined; resourceInputs["allowMajorVersionUpgrade"] = args ? args.allowMajorVersionUpgrade : undefined; resourceInputs["applyImmediately"] = args ? args.applyImmediately : undefined; resourceInputs["availabilityZones"] = args ? args.availabilityZones : undefined; resourceInputs["backtrackWindow"] = args ? args.backtrackWindow : undefined; resourceInputs["backupRetentionPeriod"] = args ? args.backupRetentionPeriod : undefined; resourceInputs["caCertificateIdentifier"] = args ? args.caCertificateIdentifier : undefined; resourceInputs["clusterIdentifier"] = args ? args.clusterIdentifier : undefined; resourceInputs["clusterIdentifierPrefix"] = args ? args.clusterIdentifierPrefix : undefined; resourceInputs["clusterMembers"] = args ? args.clusterMembers : undefined; resourceInputs["clusterScalabilityType"] = args ? args.clusterScalabilityType : undefined; resourceInputs["copyTagsToSnapshot"] = args ? args.copyTagsToSnapshot : undefined; resourceInputs["databaseInsightsMode"] = args ? args.databaseInsightsMode : undefined; resourceInputs["databaseName"] = args ? args.databaseName : undefined; resourceInputs["dbClusterInstanceClass"] = args ? args.dbClusterInstanceClass : undefined; resourceInputs["dbClusterParameterGroupName"] = args ? args.dbClusterParameterGroupName : undefined; resourceInputs["dbInstanceParameterGroupName"] = args ? args.dbInstanceParameterGroupName : undefined; resourceInputs["dbSubnetGroupName"] = args ? args.dbSubnetGroupName : undefined; resourceInputs["dbSystemId"] = args ? args.dbSystemId : undefined; resourceInputs["deleteAutomatedBackups"] = args ? args.deleteAutomatedBackups : undefined; resourceInputs["deletionProtection"] = args ? args.deletionProtection : undefined; resourceInputs["domain"] = args ? args.domain : undefined; resourceInputs["domainIamRoleName"] = args ? args.domainIamRoleName : undefined; resourceInputs["enableGlobalWriteForwarding"] = args ? args.enableGlobalWriteForwarding : undefined; resourceInputs["enableHttpEndpoint"] = args ? args.enableHttpEndpoint : undefined; resourceInputs["enableLocalWriteForwarding"] = args ? args.enableLocalWriteForwarding : undefined; resourceInputs["enabledCloudwatchLogsExports"] = args ? args.enabledCloudwatchLogsExports : undefined; resourceInputs["engine"] = args ? args.engine : undefined; resourceInputs["engineLifecycleSupport"] = args ? args.engineLifecycleSupport : undefined; resourceInputs["engineMode"] = args ? args.engineMode : undefined; resourceInputs["engineVersion"] = args ? args.engineVersion : undefined; resourceInputs["finalSnapshotIdentifier"] = args ? args.finalSnapshotIdentifier : undefined; resourceInputs["globalClusterIdentifier"] = args ? args.globalClusterIdentifier : undefined; resourceInputs["iamDatabaseAuthenticationEnabled"] = args ? args.iamDatabaseAuthenticationEnabled : undefined; resourceInputs["iamRoles"] = args ? args.iamRoles : undefined; resourceInputs["iops"] = args ? args.iops : undefined; resourceInputs["kmsKeyId"] = args ? args.kmsKeyId : undefined; resourceInputs["manageMasterUserPassword"] = args ? args.manageMasterUserPassword : undefined; resourceInputs["masterPassword"] = (args === null || args === void 0 ? void 0 : args.masterPassword) ? pulumi.secret(args.masterPassword) : undefined; resourceInputs["masterUserSecretKmsKeyId"] = args ? args.masterUserSecretKmsKeyId : undefined; resourceInputs["masterUsername"] = args ? args.masterUsername : undefined; resourceInputs["monitoringInterval"] = args ? args.monitoringInterval : undefined; resourceInputs["monitoringRoleArn"] = args ? args.monitoringRoleArn : undefined; resourceInputs["networkType"] = args ? args.networkType : undefined; resourceInputs["performanceInsightsEnabled"] = args ? args.performanceInsightsEnabled : undefined; resourceInputs["performanceInsightsKmsKeyId"] = args ? args.performanceInsightsKmsKeyId : undefined; resourceInputs["performanceInsightsRetentionPeriod"] = args ? args.performanceInsightsRetentionPeriod : undefined; resourceInputs["port"] = args ? args.port : undefined; resourceInputs["preferredBackupWindow"] = args ? args.preferredBackupWindow : undefined; resourceInputs["preferredMaintenanceWindow"] = args ? args.preferredMaintenanceWindow : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["replicationSourceIdentifier"] = args ? args.replicationSourceIdentifier : undefined; resourceInputs["restoreToPointInTime"] = args ? args.restoreToPointInTime : undefined; resourceInputs["s3Import"] = args ? args.s3Import : undefined; resourceInputs["scalingConfiguration"] = args ? args.scalingConfiguration : undefined; resourceInputs["serverlessv2ScalingConfiguration"] = args ? args.serverlessv2ScalingConfiguration : undefined; resourceInputs["skipFinalSnapshot"] = args ? args.skipFinalSnapshot : undefined; resourceInputs["snapshotIdentifier"] = args ? args.snapshotIdentifier : undefined; resourceInputs["sourceRegion"] = args ? args.sourceRegion : undefined; resourceInputs["storageEncrypted"] = args ? args.storageEncrypted : undefined; resourceInputs["storageType"] = args ? args.storageType : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["vpcSecurityGroupIds"] = args ? args.vpcSecurityGroupIds : undefined; resourceInputs["arn"] = undefined /*out*/; resourceInputs["caCertificateValidTill"] = undefined /*out*/; resourceInputs["clusterResourceId"] = undefined /*out*/; resourceInputs["endpoint"] = undefined /*out*/; resourceInputs["engineVersionActual"] = undefined /*out*/; resourceInputs["hostedZoneId"] = undefined /*out*/; resourceInputs["masterUserSecrets"] = undefined /*out*/; resourceInputs["readerEndpoint"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["masterPassword"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Cluster.__pulumiType, name, resourceInputs, opts); } } exports.Cluster = Cluster; /** @internal */ Cluster.__pulumiType = 'aws:rds/cluster:Cluster'; //# sourceMappingURL=cluster.js.map