Cluster

class Cluster : KotlinCustomResource

Manages a RDS Aurora Cluster. 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 databases (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 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 apply_immediately flag to instruct the service to apply the change immediately (see documentation below).

Note: using apply_immediately can result in a brief downtime as the server reboots. See the AWS Docs on RDS Maintenance for more information.

Example Usage

Aurora MySQL 2.x (MySQL 5.7)

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Cluster("default", ClusterArgs.builder()
.availabilityZones(
"us-west-2a",
"us-west-2b",
"us-west-2c")
.backupRetentionPeriod(5)
.clusterIdentifier("aurora-cluster-demo")
.databaseName("mydb")
.engine("aurora-mysql")
.engineVersion("5.7.mysql_aurora.2.03.2")
.masterPassword("bar")
.masterUsername("foo")
.preferredBackupWindow("07:00-09:00")
.build());
}
}

Aurora MySQL 1.x (MySQL 5.6)

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Cluster("default", ClusterArgs.builder()
.availabilityZones(
"us-west-2a",
"us-west-2b",
"us-west-2c")
.backupRetentionPeriod(5)
.clusterIdentifier("aurora-cluster-demo")
.databaseName("mydb")
.masterPassword("bar")
.masterUsername("foo")
.preferredBackupWindow("07:00-09:00")
.build());
}
}

Aurora with PostgreSQL engine

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var postgresql = new Cluster("postgresql", ClusterArgs.builder()
.availabilityZones(
"us-west-2a",
"us-west-2b",
"us-west-2c")
.backupRetentionPeriod(5)
.clusterIdentifier("aurora-cluster-demo")
.databaseName("mydb")
.engine("aurora-postgresql")
.masterPassword("bar")
.masterUsername("foo")
.preferredBackupWindow("07:00-09:00")
.build());
}
}

Aurora Multi-Master Cluster

More information about Aurora Multi-Master Clusters can be found in the RDS User Guide.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.builder()
.clusterIdentifier("example")
.dbSubnetGroupName(aws_db_subnet_group.example().name())
.engineMode("multimaster")
.masterPassword("barbarbarbar")
.masterUsername("foo")
.skipFinalSnapshot(true)
.build());
}
}

RDS Multi-AZ Cluster

More information about RDS Multi-AZ Clusters can be found in the RDS User Guide. To create a Multi-AZ RDS cluster, you must additionally specify the engine, storage_type, allocated_storage, iops and db_cluster_instance_class attributes.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.builder()
.allocatedStorage(100)
.availabilityZones(
"us-west-2a",
"us-west-2b",
"us-west-2c")
.clusterIdentifier("example")
.dbClusterInstanceClass("db.r6gd.xlarge")
.engine("mysql")
.iops(1000)
.masterPassword("mustbeeightcharaters")
.masterUsername("test")
.storageType("io1")
.build());
}
}

RDS Serverless v2 Cluster

More information about RDS Serverless v2 Clusters can be found in the RDS User Guide. To create a Serverless v2 RDS cluster, you must additionally specify the engine_mode and serverlessv2_scaling_configuration attributes. An aws.rds.ClusterInstance resource must also be added to the cluster with the instance_class attribute specified.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import com.pulumi.aws.rds.inputs.ClusterServerlessv2ScalingConfigurationArgs;
import com.pulumi.aws.rds.ClusterInstance;
import com.pulumi.aws.rds.ClusterInstanceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
.clusterIdentifier("example")
.engine("aurora-postgresql")
.engineMode("provisioned")
.engineVersion("13.6")
.databaseName("test")
.masterUsername("test")
.masterPassword("must_be_eight_characters")
.serverlessv2ScalingConfiguration(ClusterServerlessv2ScalingConfigurationArgs.builder()
.maxCapacity(1)
.minCapacity(0.5)
.build())
.build());
var exampleClusterInstance = new ClusterInstance("exampleClusterInstance", ClusterInstanceArgs.builder()
.clusterIdentifier(exampleCluster.id())
.instanceClass("db.serverless")
.engine(exampleCluster.engine())
.engineVersion(exampleCluster.engineVersion())
.build());
}
}

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 and Aurora User Guide. You can specify the manage_master_user_password attribute to enable managing the master password with Secrets Manager. You can also update an existing cluster to use Secrets Manager by specify the manage_master_user_password attribute and removing the master_password attribute (removal is required).

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new Cluster("test", ClusterArgs.builder()
.clusterIdentifier("example")
.databaseName("test")
.manageMasterUserPassword(true)
.masterUsername("test")
.build());
}
}

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 and Aurora User Guide. You can specify the master_user_secret_kms_key_id attribute to specify a specific KMS Key.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Key("example", KeyArgs.builder()
.description("Example KMS Key")
.build());
var test = new Cluster("test", ClusterArgs.builder()
.clusterIdentifier("example")
.databaseName("test")
.manageMasterUserPassword(true)
.masterUsername("test")
.masterUserSecretKmsKeyId(example.keyId())
.build());
}
}

Global Cluster Restored From Snapshot

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.rds.RdsFunctions;
import com.pulumi.aws.rds.inputs.GetClusterSnapshotArgs;
import com.pulumi.aws.rds.Cluster;
import com.pulumi.aws.rds.ClusterArgs;
import com.pulumi.aws.rds.GlobalCluster;
import com.pulumi.aws.rds.GlobalClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var exampleClusterSnapshot = RdsFunctions.getClusterSnapshot(GetClusterSnapshotArgs.builder()
.dbClusterIdentifier("example-original-cluster")
.mostRecent(true)
.build());
var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
.engine("aurora")
.engineVersion("5.6.mysql_aurora.1.22.4")
.clusterIdentifier("example")
.snapshotIdentifier(exampleClusterSnapshot.applyValue(getClusterSnapshotResult -> getClusterSnapshotResult.id()))
.build());
var exampleGlobalCluster = new GlobalCluster("exampleGlobalCluster", GlobalClusterArgs.builder()
.globalClusterIdentifier("example")
.sourceDbClusterIdentifier(exampleCluster.arn())
.forceDestroy(true)
.build());
}
}

Import

RDS Clusters can be imported using the cluster_identifier, e.g.,

$ pulumi import aws:rds/cluster:Cluster aurora_cluster aurora-prod-cluster

Properties

Link copied to clipboard
val allocatedStorage: Output<Int>

(Required for Multi-AZ DB cluster) The amount of storage in gibibytes (GiB) to allocate to each DB instance in the Multi-AZ DB cluster.

Link copied to clipboard

Enable to allow major engine version upgrades when changing engine versions. Defaults to false.

Link copied to clipboard

Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is false. See Amazon RDS Documentation for more information.

Link copied to clipboard
val arn: Output<String>

Amazon Resource Name (ARN) of cluster

Link copied to clipboard

List of EC2 Availability Zones for the DB cluster storage where DB cluster instances can be created. RDS automatically assigns 3 AZs if less than 3 AZs are configured, which will show as a difference requiring resource recreation next apply. We recommend specifying 3 AZs or using the lifecycle configuration block ignore_changes argument if necessary. A maximum of 3 AZs can be configured.

Link copied to clipboard
val backtrackWindow: Output<Int>?

The target backtrack window, in seconds. Only available for aurora and aurora-mysql engines currently. To disable backtracking, set this value to 0. Defaults to 0. Must be between 0 and 259200 (72 hours)

Link copied to clipboard

The days to retain backups for. Default 1

Link copied to clipboard

The cluster identifier. If omitted, this provider will assign a random, unique identifier.

Link copied to clipboard

Creates a unique cluster identifier beginning with the specified prefix. Conflicts with cluster_identifier.

Link copied to clipboard
val clusterMembers: Output<List<String>>

List of RDS Instances that are a part of this cluster

Link copied to clipboard

The RDS Cluster Resource ID

Link copied to clipboard

Copy all Cluster tags to snapshots. Default is false.

Link copied to clipboard
val databaseName: Output<String>

Name for an automatically created database on cluster creation. There are different naming restrictions per database engine: RDS Naming Constraints

Link copied to clipboard

(Required for Multi-AZ DB cluster) The compute and memory capacity of each DB instance in the Multi-AZ DB cluster, for example db.m6g.xlarge. Not all DB instance classes are available in all AWS Regions, or for all database engines. For the full list of DB instance classes and availability for your engine, see DB instance class in the Amazon RDS User Guide.

Link copied to clipboard

A cluster parameter group to associate with the cluster.

Link copied to clipboard

Instance parameter group to associate with all instances of the DB cluster. The db_instance_parameter_group_name parameter is only valid in combination with the allow_major_version_upgrade parameter.

Link copied to clipboard

A DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name specified on every aws.rds.ClusterInstance in the cluster.

Link copied to clipboard

If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. The default is false.

Link copied to clipboard

Set of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, error, general, slowquery, postgresql (PostgreSQL).

Link copied to clipboard

Whether cluster should forward writes to an associated global cluster. Applied to secondary clusters to enable them to forward writes to an aws.rds.GlobalCluster's primary cluster. See the Aurora Userguide documentation for more information.

Link copied to clipboard

Enable HTTP endpoint (data API). Only valid when engine_mode is set to serverless.

Link copied to clipboard
val endpoint: Output<String>

The DNS address of the RDS instance

Link copied to clipboard
val engine: Output<String>?

The name of the database engine to be used for this DB cluster. Defaults to aurora. Valid Values: aurora, aurora-mysql, aurora-postgresql, mysql, postgres. (Note that mysql and postgres are Multi-AZ RDS clusters).

Link copied to clipboard
val engineMode: Output<String>?

The database engine mode. Valid values: global (only valid for Aurora MySQL 1.21 and earlier), multimaster, parallelquery, provisioned, serverless. Defaults to: provisioned. See the RDS User Guide for limitations when using serverless.

Link copied to clipboard
val engineVersion: Output<String>

The database engine version. Updating this argument results in an outage. See the Aurora MySQL and Aurora Postgres documentation for your configured engine to determine this value, or by running aws rds describe-db-engine-versions. For example with Aurora MySQL 2, a potential value for this argument is 5.7.mysql_aurora.2.03.2. The value can contain a partial version where supported by the API. The actual engine version used is returned in the attribute engine_version_actual, , see Attributes Reference below.

Link copied to clipboard

The running version of the database.

Link copied to clipboard

The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made.

Link copied to clipboard

The global cluster identifier specified on aws.rds.GlobalCluster.

Link copied to clipboard
val hostedZoneId: Output<String>

The Route53 Hosted Zone ID of the endpoint

Link copied to clipboard

Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. Please see AWS Documentation for availability and limitations.

Link copied to clipboard
val iamRoles: Output<List<String>>

A List of ARNs for the IAM roles to associate to the RDS Cluster.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val iops: Output<Int>?

(Required for Multi-AZ DB cluster) The amount of Provisioned IOPS (input/output operations per second) to be initially allocated for each DB instance in the Multi-AZ DB cluster. For information about valid Iops values, see Amazon RDS Provisioned IOPS storage to improve performance in the Amazon RDS User Guide. Must be a multiple between .5 and 50 of the storage amount for the DB cluster.

Link copied to clipboard
val kmsKeyId: Output<String>

The ARN for the KMS encryption key. When specifying kms_key_id, storage_encrypted needs to be set to true.

Link copied to clipboard

Set to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if master_password is provided.

Link copied to clipboard
val masterPassword: Output<String>?

Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Please refer to the RDS Naming Constraints. Cannot be set if manage_master_user_password is set to true.

Link copied to clipboard
val masterUsername: Output<String>

Username for the master DB user. Please refer to the RDS Naming Constraints. This argument does not support in-place updates and cannot be changed during a restore from snapshot.

Link copied to clipboard

The Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN. If not specified, the default KMS key for your Amazon Web Services account is used.

Link copied to clipboard

A block that specifies the master user secret. Only available when manage_master_user_password is set to true. Documented below.

Link copied to clipboard
val networkType: Output<String>

The network type of the cluster. Valid values: IPV4, DUAL.

Link copied to clipboard
val port: Output<Int>

The port on which the DB accepts connections

Link copied to clipboard

The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter.Time in UTC. Default: A 30-minute window selected at random from an 8-hour block of time per regionE.g., 04:00-09:00

Link copied to clipboard

The weekly time range during which system maintenance can occur, in (UTC) e.g., wed:04:00-wed:04:30

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val readerEndpoint: Output<String>

A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas

Link copied to clipboard

ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. If DB Cluster is part of a Global Cluster, use the lifecycle configuration block ignore_changes argument to prevent this provider from showing differences for this argument instead of configuring this value.

Link copied to clipboard

Nested attribute for point in time restore. More details below.

Link copied to clipboard
Link copied to clipboard

Nested attribute with scaling properties. Only valid when engine_mode is set to serverless. More details below.

Link copied to clipboard

Nested attribute with scaling properties for ServerlessV2. Only valid when engine_mode is set to provisioned. More details below.

Link copied to clipboard

Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false.

Link copied to clipboard

Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot. Conflicts with global_cluster_identifier. Clusters cannot be restored from snapshot and joined to an existing global cluster in a single operation. See the AWS documentation or the Global Cluster Restored From Snapshot example for instructions on building a global cluster starting with a snapshot.

Link copied to clipboard
val sourceRegion: Output<String>?

The source region for an encrypted replica DB cluster.

Link copied to clipboard

Specifies whether the DB cluster is encrypted. The default is false for provisioned engine_mode and true for serverless engine_mode. When restoring an unencrypted snapshot_identifier, the kms_key_id argument must be provided to encrypt the restored cluster. The provider will only perform drift detection if a configuration value is provided.

Link copied to clipboard
val storageType: Output<String>

(Required for Multi-AZ DB clusters) (Forces new for Multi-AZ DB clusters) Specifies the storage type to be associated with the DB cluster. For Aurora DB clusters, storage_type modifications can be done in-place. For Multi-AZ DB Clusters, the iops argument must also be set. Valid values are: "", aurora-iopt1 (Aurora DB Clusters); io1 (Multi-AZ DB Clusters). Default: "" (Aurora DB Clusters); io1 (Multi-AZ DB Clusters).

Link copied to clipboard
val tags: Output<Map<String, String>>?

A map of tags to assign to the DB cluster. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val tagsAll: Output<Map<String, String>>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard

List of VPC security groups to associate with the Cluster