UNPKG

@pulumi/aws

Version:

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

412 lines • 22.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! *** 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, { ...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?.allocatedStorage; resourceInputs["allowMajorVersionUpgrade"] = state?.allowMajorVersionUpgrade; resourceInputs["applyImmediately"] = state?.applyImmediately; resourceInputs["arn"] = state?.arn; resourceInputs["availabilityZones"] = state?.availabilityZones; resourceInputs["backtrackWindow"] = state?.backtrackWindow; resourceInputs["backupRetentionPeriod"] = state?.backupRetentionPeriod; resourceInputs["caCertificateIdentifier"] = state?.caCertificateIdentifier; resourceInputs["caCertificateValidTill"] = state?.caCertificateValidTill; resourceInputs["clusterIdentifier"] = state?.clusterIdentifier; resourceInputs["clusterIdentifierPrefix"] = state?.clusterIdentifierPrefix; resourceInputs["clusterMembers"] = state?.clusterMembers; resourceInputs["clusterResourceId"] = state?.clusterResourceId; resourceInputs["clusterScalabilityType"] = state?.clusterScalabilityType; resourceInputs["copyTagsToSnapshot"] = state?.copyTagsToSnapshot; resourceInputs["databaseInsightsMode"] = state?.databaseInsightsMode; resourceInputs["databaseName"] = state?.databaseName; resourceInputs["dbClusterInstanceClass"] = state?.dbClusterInstanceClass; resourceInputs["dbClusterParameterGroupName"] = state?.dbClusterParameterGroupName; resourceInputs["dbInstanceParameterGroupName"] = state?.dbInstanceParameterGroupName; resourceInputs["dbSubnetGroupName"] = state?.dbSubnetGroupName; resourceInputs["dbSystemId"] = state?.dbSystemId; resourceInputs["deleteAutomatedBackups"] = state?.deleteAutomatedBackups; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["domain"] = state?.domain; resourceInputs["domainIamRoleName"] = state?.domainIamRoleName; resourceInputs["enableGlobalWriteForwarding"] = state?.enableGlobalWriteForwarding; resourceInputs["enableHttpEndpoint"] = state?.enableHttpEndpoint; resourceInputs["enableLocalWriteForwarding"] = state?.enableLocalWriteForwarding; resourceInputs["enabledCloudwatchLogsExports"] = state?.enabledCloudwatchLogsExports; resourceInputs["endpoint"] = state?.endpoint; resourceInputs["engine"] = state?.engine; resourceInputs["engineLifecycleSupport"] = state?.engineLifecycleSupport; resourceInputs["engineMode"] = state?.engineMode; resourceInputs["engineVersion"] = state?.engineVersion; resourceInputs["engineVersionActual"] = state?.engineVersionActual; resourceInputs["finalSnapshotIdentifier"] = state?.finalSnapshotIdentifier; resourceInputs["globalClusterIdentifier"] = state?.globalClusterIdentifier; resourceInputs["hostedZoneId"] = state?.hostedZoneId; resourceInputs["iamDatabaseAuthenticationEnabled"] = state?.iamDatabaseAuthenticationEnabled; resourceInputs["iamRoles"] = state?.iamRoles; resourceInputs["iops"] = state?.iops; resourceInputs["kmsKeyId"] = state?.kmsKeyId; resourceInputs["manageMasterUserPassword"] = state?.manageMasterUserPassword; resourceInputs["masterPassword"] = state?.masterPassword; resourceInputs["masterUserSecretKmsKeyId"] = state?.masterUserSecretKmsKeyId; resourceInputs["masterUserSecrets"] = state?.masterUserSecrets; resourceInputs["masterUsername"] = state?.masterUsername; resourceInputs["monitoringInterval"] = state?.monitoringInterval; resourceInputs["monitoringRoleArn"] = state?.monitoringRoleArn; resourceInputs["networkType"] = state?.networkType; resourceInputs["performanceInsightsEnabled"] = state?.performanceInsightsEnabled; resourceInputs["performanceInsightsKmsKeyId"] = state?.performanceInsightsKmsKeyId; resourceInputs["performanceInsightsRetentionPeriod"] = state?.performanceInsightsRetentionPeriod; resourceInputs["port"] = state?.port; resourceInputs["preferredBackupWindow"] = state?.preferredBackupWindow; resourceInputs["preferredMaintenanceWindow"] = state?.preferredMaintenanceWindow; resourceInputs["readerEndpoint"] = state?.readerEndpoint; resourceInputs["region"] = state?.region; resourceInputs["replicationSourceIdentifier"] = state?.replicationSourceIdentifier; resourceInputs["restoreToPointInTime"] = state?.restoreToPointInTime; resourceInputs["s3Import"] = state?.s3Import; resourceInputs["scalingConfiguration"] = state?.scalingConfiguration; resourceInputs["serverlessv2ScalingConfiguration"] = state?.serverlessv2ScalingConfiguration; resourceInputs["skipFinalSnapshot"] = state?.skipFinalSnapshot; resourceInputs["snapshotIdentifier"] = state?.snapshotIdentifier; resourceInputs["sourceRegion"] = state?.sourceRegion; resourceInputs["storageEncrypted"] = state?.storageEncrypted; resourceInputs["storageType"] = state?.storageType; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["vpcSecurityGroupIds"] = state?.vpcSecurityGroupIds; } else { const args = argsOrState; if (args?.engine === undefined && !opts.urn) { throw new Error("Missing required property 'engine'"); } resourceInputs["allocatedStorage"] = args?.allocatedStorage; resourceInputs["allowMajorVersionUpgrade"] = args?.allowMajorVersionUpgrade; resourceInputs["applyImmediately"] = args?.applyImmediately; resourceInputs["availabilityZones"] = args?.availabilityZones; resourceInputs["backtrackWindow"] = args?.backtrackWindow; resourceInputs["backupRetentionPeriod"] = args?.backupRetentionPeriod; resourceInputs["caCertificateIdentifier"] = args?.caCertificateIdentifier; resourceInputs["clusterIdentifier"] = args?.clusterIdentifier; resourceInputs["clusterIdentifierPrefix"] = args?.clusterIdentifierPrefix; resourceInputs["clusterMembers"] = args?.clusterMembers; resourceInputs["clusterScalabilityType"] = args?.clusterScalabilityType; resourceInputs["copyTagsToSnapshot"] = args?.copyTagsToSnapshot; resourceInputs["databaseInsightsMode"] = args?.databaseInsightsMode; resourceInputs["databaseName"] = args?.databaseName; resourceInputs["dbClusterInstanceClass"] = args?.dbClusterInstanceClass; resourceInputs["dbClusterParameterGroupName"] = args?.dbClusterParameterGroupName; resourceInputs["dbInstanceParameterGroupName"] = args?.dbInstanceParameterGroupName; resourceInputs["dbSubnetGroupName"] = args?.dbSubnetGroupName; resourceInputs["dbSystemId"] = args?.dbSystemId; resourceInputs["deleteAutomatedBackups"] = args?.deleteAutomatedBackups; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["domain"] = args?.domain; resourceInputs["domainIamRoleName"] = args?.domainIamRoleName; resourceInputs["enableGlobalWriteForwarding"] = args?.enableGlobalWriteForwarding; resourceInputs["enableHttpEndpoint"] = args?.enableHttpEndpoint; resourceInputs["enableLocalWriteForwarding"] = args?.enableLocalWriteForwarding; resourceInputs["enabledCloudwatchLogsExports"] = args?.enabledCloudwatchLogsExports; resourceInputs["engine"] = args?.engine; resourceInputs["engineLifecycleSupport"] = args?.engineLifecycleSupport; resourceInputs["engineMode"] = args?.engineMode; resourceInputs["engineVersion"] = args?.engineVersion; resourceInputs["finalSnapshotIdentifier"] = args?.finalSnapshotIdentifier; resourceInputs["globalClusterIdentifier"] = args?.globalClusterIdentifier; resourceInputs["iamDatabaseAuthenticationEnabled"] = args?.iamDatabaseAuthenticationEnabled; resourceInputs["iamRoles"] = args?.iamRoles; resourceInputs["iops"] = args?.iops; resourceInputs["kmsKeyId"] = args?.kmsKeyId; resourceInputs["manageMasterUserPassword"] = args?.manageMasterUserPassword; resourceInputs["masterPassword"] = args?.masterPassword ? pulumi.secret(args.masterPassword) : undefined; resourceInputs["masterUserSecretKmsKeyId"] = args?.masterUserSecretKmsKeyId; resourceInputs["masterUsername"] = args?.masterUsername; resourceInputs["monitoringInterval"] = args?.monitoringInterval; resourceInputs["monitoringRoleArn"] = args?.monitoringRoleArn; resourceInputs["networkType"] = args?.networkType; resourceInputs["performanceInsightsEnabled"] = args?.performanceInsightsEnabled; resourceInputs["performanceInsightsKmsKeyId"] = args?.performanceInsightsKmsKeyId; resourceInputs["performanceInsightsRetentionPeriod"] = args?.performanceInsightsRetentionPeriod; resourceInputs["port"] = args?.port; resourceInputs["preferredBackupWindow"] = args?.preferredBackupWindow; resourceInputs["preferredMaintenanceWindow"] = args?.preferredMaintenanceWindow; resourceInputs["region"] = args?.region; resourceInputs["replicationSourceIdentifier"] = args?.replicationSourceIdentifier; resourceInputs["restoreToPointInTime"] = args?.restoreToPointInTime; resourceInputs["s3Import"] = args?.s3Import; resourceInputs["scalingConfiguration"] = args?.scalingConfiguration; resourceInputs["serverlessv2ScalingConfiguration"] = args?.serverlessv2ScalingConfiguration; resourceInputs["skipFinalSnapshot"] = args?.skipFinalSnapshot; resourceInputs["snapshotIdentifier"] = args?.snapshotIdentifier; resourceInputs["sourceRegion"] = args?.sourceRegion; resourceInputs["storageEncrypted"] = args?.storageEncrypted; resourceInputs["storageType"] = args?.storageType; resourceInputs["tags"] = args?.tags; resourceInputs["vpcSecurityGroupIds"] = args?.vpcSecurityGroupIds; 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