Cluster
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
anddb_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
andserverlessv2_scaling_configuration
attributes. Anaws.rds.ClusterInstance
resource must also be added to the cluster with theinstance_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());
}
}
Import
RDS Clusters can be imported using the cluster_identifier
, e.g.,
$ pulumi import aws:rds/cluster:Cluster aurora_cluster aurora-prod-cluster
Properties
Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is false
. See Amazon RDS Documentation for more information.
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.
Name for an automatically created database on cluster creation. There are different naming restrictions per database engine: RDS Naming Constraints
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. (This setting is required to create a Multi-AZ DB cluster).
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.
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
.
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. 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.
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.
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. (This setting is required to create a Multi-AZ DB cluster). Must be a multiple between .5 and 50 of the storage amount for the DB cluster.
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
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.
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.
Nested attribute for point in time restore. More details below.
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.