Class DatabaseCluster.Builder

java.lang.Object
software.amazon.awscdk.services.rds.DatabaseCluster.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<DatabaseCluster>
Enclosing class:
DatabaseCluster

@Stability(Stable) public static final class DatabaseCluster.Builder extends Object implements software.amazon.jsii.Builder<DatabaseCluster>
A fluent builder for DatabaseCluster.
  • Method Details

    • create

      @Stability(Stable) public static DatabaseCluster.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of DatabaseCluster.Builder.
    • engine

      @Stability(Stable) public DatabaseCluster.Builder engine(IClusterEngine engine)
      What kind of database to start.

      Parameters:
      engine - What kind of database to start. This parameter is required.
      Returns:
      this
    • autoMinorVersionUpgrade

      @Stability(Stable) public DatabaseCluster.Builder autoMinorVersionUpgrade(Boolean autoMinorVersionUpgrade)
      Specifies whether minor engine upgrades are applied automatically to the DB cluster during the maintenance window.

      Default: true

      Parameters:
      autoMinorVersionUpgrade - Specifies whether minor engine upgrades are applied automatically to the DB cluster during the maintenance window. This parameter is required.
      Returns:
      this
    • backtrackWindow

      @Stability(Stable) public DatabaseCluster.Builder backtrackWindow(Duration backtrackWindow)
      The number of seconds to set a cluster's target backtrack window to.

      This feature is only supported by the Aurora MySQL database engine and cannot be enabled on existing clusters.

      Default: 0 seconds (no backtrack)

      Parameters:
      backtrackWindow - The number of seconds to set a cluster's target backtrack window to. This parameter is required.
      Returns:
      this
      See Also:
    • backup

      @Stability(Stable) public DatabaseCluster.Builder backup(BackupProps backup)
      Backup settings.

      Default: - Backup retention period for automated backups is 1 day. Backup preferred window is set to a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

      Parameters:
      backup - Backup settings. This parameter is required.
      Returns:
      this
      See Also:
    • cloudwatchLogsExports

      @Stability(Stable) public DatabaseCluster.Builder cloudwatchLogsExports(List<String> cloudwatchLogsExports)
      The list of log types that need to be enabled for exporting to CloudWatch Logs.

      Default: - no log exports

      Parameters:
      cloudwatchLogsExports - The list of log types that need to be enabled for exporting to CloudWatch Logs. This parameter is required.
      Returns:
      this
    • cloudwatchLogsRetention

      @Stability(Stable) public DatabaseCluster.Builder cloudwatchLogsRetention(RetentionDays cloudwatchLogsRetention)
      The number of days log events are kept in CloudWatch Logs.

      When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to Infinity.

      Default: - logs never expire

      Parameters:
      cloudwatchLogsRetention - The number of days log events are kept in CloudWatch Logs. This parameter is required.
      Returns:
      this
    • cloudwatchLogsRetentionRole

      @Stability(Stable) public DatabaseCluster.Builder cloudwatchLogsRetentionRole(IRole cloudwatchLogsRetentionRole)
      The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

      Default: - a new role is created.

      Parameters:
      cloudwatchLogsRetentionRole - The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This parameter is required.
      Returns:
      this
    • clusterIdentifier

      @Stability(Stable) public DatabaseCluster.Builder clusterIdentifier(String clusterIdentifier)
      An optional identifier for the cluster.

      Default: - A name is automatically generated.

      Parameters:
      clusterIdentifier - An optional identifier for the cluster. This parameter is required.
      Returns:
      this
    • clusterScailabilityType

      @Stability(Stable) public DatabaseCluster.Builder clusterScailabilityType(ClusterScailabilityType clusterScailabilityType)
      Specifies the scalability mode of the Aurora DB cluster.

      Set LIMITLESS if you want to use a limitless database; otherwise, set it to STANDARD.

      Default: ClusterScailabilityType.STANDARD

      Parameters:
      clusterScailabilityType - Specifies the scalability mode of the Aurora DB cluster. This parameter is required.
      Returns:
      this
    • copyTagsToSnapshot

      @Stability(Stable) public DatabaseCluster.Builder copyTagsToSnapshot(Boolean copyTagsToSnapshot)
      Whether to copy tags to the snapshot when a snapshot is created.

      Default: - true

      Parameters:
      copyTagsToSnapshot - Whether to copy tags to the snapshot when a snapshot is created. This parameter is required.
      Returns:
      this
    • credentials

      @Stability(Stable) public DatabaseCluster.Builder credentials(Credentials credentials)
      Credentials for the administrative user.

      Default: - A username of 'admin' (or 'postgres' for PostgreSQL) and SecretsManager-generated password

      Parameters:
      credentials - Credentials for the administrative user. This parameter is required.
      Returns:
      this
    • defaultDatabaseName

      @Stability(Stable) public DatabaseCluster.Builder defaultDatabaseName(String defaultDatabaseName)
      Name of a database which is automatically created inside the cluster.

      Default: - Database is not created in cluster.

      Parameters:
      defaultDatabaseName - Name of a database which is automatically created inside the cluster. This parameter is required.
      Returns:
      this
    • deletionProtection

      @Stability(Stable) public DatabaseCluster.Builder deletionProtection(Boolean deletionProtection)
      Indicates whether the DB cluster should have deletion protection enabled.

      Default: - true if `removalPolicy` is RETAIN, `undefined` otherwise, which will not enable deletion protection. To disable deletion protection after it has been enabled, you must explicitly set this value to `false`.

      Parameters:
      deletionProtection - Indicates whether the DB cluster should have deletion protection enabled. This parameter is required.
      Returns:
      this
    • domain

      @Stability(Stable) public DatabaseCluster.Builder domain(String domain)
      Directory ID for associating the DB cluster with a specific Active Directory.

      Necessary for enabling Kerberos authentication. If specified, the DB cluster joins the given Active Directory, enabling Kerberos authentication. If not specified, the DB cluster will not be associated with any Active Directory, and Kerberos authentication will not be enabled.

      Default: - DB cluster is not associated with an Active Directory; Kerberos authentication is not enabled.

      Parameters:
      domain - Directory ID for associating the DB cluster with a specific Active Directory. This parameter is required.
      Returns:
      this
    • domainRole

      @Stability(Stable) public DatabaseCluster.Builder domainRole(IRole domainRole)
      The IAM role to be used when making API calls to the Directory Service.

      The role needs the AWS-managed policy AmazonRDSDirectoryServiceAccess or equivalent.

      Default: - If `DatabaseClusterBaseProps.domain` is specified, a role with the `AmazonRDSDirectoryServiceAccess` policy is automatically created.

      Parameters:
      domainRole - The IAM role to be used when making API calls to the Directory Service. This parameter is required.
      Returns:
      this
    • enableClusterLevelEnhancedMonitoring

      @Stability(Stable) public DatabaseCluster.Builder enableClusterLevelEnhancedMonitoring(Boolean enableClusterLevelEnhancedMonitoring)
      Whether to enable enhanced monitoring at the cluster level.

      If set to true, monitoringInterval and monitoringRole are applied to not the instances, but the cluster. monitoringInterval is required to be set if enableClusterLevelEnhancedMonitoring is set to true.

      Default: - When the `monitoringInterval` is set, enhanced monitoring is enabled for each instance.

      Parameters:
      enableClusterLevelEnhancedMonitoring - Whether to enable enhanced monitoring at the cluster level. This parameter is required.
      Returns:
      this
    • enableDataApi

      @Stability(Stable) public DatabaseCluster.Builder enableDataApi(Boolean enableDataApi)
      Whether to enable the Data API for the cluster.

      Default: - false

      Parameters:
      enableDataApi - Whether to enable the Data API for the cluster. This parameter is required.
      Returns:
      this
    • enableLocalWriteForwarding

      @Stability(Stable) public DatabaseCluster.Builder enableLocalWriteForwarding(Boolean enableLocalWriteForwarding)
      Whether read replicas can forward write operations to the writer DB instance in the DB cluster.

      This setting can only be enabled for Aurora MySQL 3.04 or higher, and for Aurora PostgreSQL 16.4 or higher (for version 16), 15.8 or higher (for version 15), and 14.13 or higher (for version 14).

      Default: false

      Parameters:
      enableLocalWriteForwarding - Whether read replicas can forward write operations to the writer DB instance in the DB cluster. This parameter is required.
      Returns:
      this
      See Also:
    • enablePerformanceInsights

      @Stability(Stable) public DatabaseCluster.Builder enablePerformanceInsights(Boolean enablePerformanceInsights)
      Whether to enable Performance Insights for the DB cluster.

      Default: - false, unless `performanceInsightRetention` or `performanceInsightEncryptionKey` is set.

      Parameters:
      enablePerformanceInsights - Whether to enable Performance Insights for the DB cluster. This parameter is required.
      Returns:
      this
    • iamAuthentication

      @Stability(Stable) public DatabaseCluster.Builder iamAuthentication(Boolean iamAuthentication)
      Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts.

      Default: false

      Parameters:
      iamAuthentication - Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts. This parameter is required.
      Returns:
      this
    • instanceIdentifierBase

      @Stability(Stable) public DatabaseCluster.Builder instanceIdentifierBase(String instanceIdentifierBase)
      Base identifier for instances.

      Every replica is named by appending the replica number to this string, 1-based.

      Default: - clusterIdentifier is used with the word "Instance" appended. If clusterIdentifier is not provided, the identifier is automatically generated.

      Parameters:
      instanceIdentifierBase - Base identifier for instances. This parameter is required.
      Returns:
      this
    • instanceProps

      @Stability(Deprecated) @Deprecated public DatabaseCluster.Builder instanceProps(InstanceProps instanceProps)
      Deprecated.
      • use writer and readers instead
      (deprecated) Settings for the individual instances that are launched.

      Parameters:
      instanceProps - Settings for the individual instances that are launched. This parameter is required.
      Returns:
      this
    • instances

      @Stability(Deprecated) @Deprecated public DatabaseCluster.Builder instances(Number instances)
      Deprecated.
      • use writer and readers instead
      (deprecated) How many replicas/instances to create.

      Has to be at least 1.

      Default: 2

      Parameters:
      instances - How many replicas/instances to create. This parameter is required.
      Returns:
      this
    • instanceUpdateBehaviour

      @Stability(Stable) public DatabaseCluster.Builder instanceUpdateBehaviour(InstanceUpdateBehaviour instanceUpdateBehaviour)
      The ordering of updates for instances.

      Default: InstanceUpdateBehaviour.BULK

      Parameters:
      instanceUpdateBehaviour - The ordering of updates for instances. This parameter is required.
      Returns:
      this
    • monitoringInterval

      @Stability(Stable) public DatabaseCluster.Builder monitoringInterval(Duration monitoringInterval)
      The interval between points when Amazon RDS collects enhanced monitoring metrics.

      If you enable enableClusterLevelEnhancedMonitoring, this property is applied to the cluster, otherwise it is applied to the instances.

      Default: - no enhanced monitoring

      Parameters:
      monitoringInterval - The interval between points when Amazon RDS collects enhanced monitoring metrics. This parameter is required.
      Returns:
      this
    • monitoringRole

      @Stability(Stable) public DatabaseCluster.Builder monitoringRole(IRole monitoringRole)
      Role that will be used to manage DB monitoring.

      If you enable enableClusterLevelEnhancedMonitoring, this property is applied to the cluster, otherwise it is applied to the instances.

      Default: - A role is automatically created for you

      Parameters:
      monitoringRole - Role that will be used to manage DB monitoring. This parameter is required.
      Returns:
      this
    • networkType

      @Stability(Stable) public DatabaseCluster.Builder networkType(NetworkType networkType)
      The network type of the DB instance.

      Default: - IPV4

      Parameters:
      networkType - The network type of the DB instance. This parameter is required.
      Returns:
      this
    • parameterGroup

      @Stability(Stable) public DatabaseCluster.Builder parameterGroup(IParameterGroup parameterGroup)
      Additional parameters to pass to the database engine.

      Default: - No parameter group.

      Parameters:
      parameterGroup - Additional parameters to pass to the database engine. This parameter is required.
      Returns:
      this
    • parameters

      @Stability(Stable) public DatabaseCluster.Builder parameters(Map<String,String> parameters)
      The parameters in the DBClusterParameterGroup to create automatically.

      You can only specify parameterGroup or parameters but not both. You need to use a versioned engine to auto-generate a DBClusterParameterGroup.

      Default: - None

      Parameters:
      parameters - The parameters in the DBClusterParameterGroup to create automatically. This parameter is required.
      Returns:
      this
    • performanceInsightEncryptionKey

      @Stability(Stable) public DatabaseCluster.Builder performanceInsightEncryptionKey(IKey performanceInsightEncryptionKey)
      The AWS KMS key for encryption of Performance Insights data.

      Default: - default master key

      Parameters:
      performanceInsightEncryptionKey - The AWS KMS key for encryption of Performance Insights data. This parameter is required.
      Returns:
      this
    • performanceInsightRetention

      @Stability(Stable) public DatabaseCluster.Builder performanceInsightRetention(PerformanceInsightRetention performanceInsightRetention)
      The amount of time, in days, to retain Performance Insights data.

      Default: 7

      Parameters:
      performanceInsightRetention - The amount of time, in days, to retain Performance Insights data. This parameter is required.
      Returns:
      this
    • port

      @Stability(Stable) public DatabaseCluster.Builder port(Number port)
      What port to listen on.

      Default: - The default for the engine is used.

      Parameters:
      port - What port to listen on. This parameter is required.
      Returns:
      this
    • preferredMaintenanceWindow

      @Stability(Stable) public DatabaseCluster.Builder preferredMaintenanceWindow(String preferredMaintenanceWindow)
      A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC).

      Example: 'Sun:23:45-Mon:00:15'

      Default: - 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

      Parameters:
      preferredMaintenanceWindow - A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). This parameter is required.
      Returns:
      this
      See Also:
    • readers

      @Stability(Stable) public DatabaseCluster.Builder readers(List<? extends IClusterInstance> readers)
      A list of instances to create as cluster reader instances.

      Default: - no readers are created. The cluster will have a single writer/reader

      Parameters:
      readers - A list of instances to create as cluster reader instances. This parameter is required.
      Returns:
      this
    • removalPolicy

      @Stability(Stable) public DatabaseCluster.Builder removalPolicy(RemovalPolicy removalPolicy)
      The removal policy to apply when the cluster and its instances are removed from the stack or replaced during an update.

      Default: - RemovalPolicy.SNAPSHOT (remove the cluster and instances, but retain a snapshot of the data)

      Parameters:
      removalPolicy - The removal policy to apply when the cluster and its instances are removed from the stack or replaced during an update. This parameter is required.
      Returns:
      this
    • s3ExportBuckets

      @Stability(Stable) public DatabaseCluster.Builder s3ExportBuckets(List<? extends IBucket> s3ExportBuckets)
      S3 buckets that you want to load data into. This feature is only supported by the Aurora database engine.

      This property must not be used if s3ExportRole is used.

      For MySQL:

      Default: - None

      Parameters:
      s3ExportBuckets - S3 buckets that you want to load data into. This feature is only supported by the Aurora database engine. This parameter is required.
      Returns:
      this
      See Also:
    • s3ExportRole

      @Stability(Stable) public DatabaseCluster.Builder s3ExportRole(IRole s3ExportRole)
      Role that will be associated with this DB cluster to enable S3 export.

      This feature is only supported by the Aurora database engine.

      This property must not be used if s3ExportBuckets is used. To use this property with Aurora PostgreSQL, it must be configured with the S3 export feature enabled when creating the DatabaseClusterEngine For MySQL:

      Default: - New role is created if `s3ExportBuckets` is set, no role is defined otherwise

      Parameters:
      s3ExportRole - Role that will be associated with this DB cluster to enable S3 export. This parameter is required.
      Returns:
      this
      See Also:
    • s3ImportBuckets

      @Stability(Stable) public DatabaseCluster.Builder s3ImportBuckets(List<? extends IBucket> s3ImportBuckets)
      S3 buckets that you want to load data from. This feature is only supported by the Aurora database engine.

      This property must not be used if s3ImportRole is used.

      For MySQL:

      Default: - None

      Parameters:
      s3ImportBuckets - S3 buckets that you want to load data from. This feature is only supported by the Aurora database engine. This parameter is required.
      Returns:
      this
      See Also:
    • s3ImportRole

      @Stability(Stable) public DatabaseCluster.Builder s3ImportRole(IRole s3ImportRole)
      Role that will be associated with this DB cluster to enable S3 import.

      This feature is only supported by the Aurora database engine.

      This property must not be used if s3ImportBuckets is used. To use this property with Aurora PostgreSQL, it must be configured with the S3 import feature enabled when creating the DatabaseClusterEngine For MySQL:

      Default: - New role is created if `s3ImportBuckets` is set, no role is defined otherwise

      Parameters:
      s3ImportRole - Role that will be associated with this DB cluster to enable S3 import. This parameter is required.
      Returns:
      this
      See Also:
    • securityGroups

      @Stability(Stable) public DatabaseCluster.Builder securityGroups(List<? extends ISecurityGroup> securityGroups)
      Security group.

      Default: - a new security group is created.

      Parameters:
      securityGroups - Security group. This parameter is required.
      Returns:
      this
    • serverlessV2MaxCapacity

      @Stability(Stable) public DatabaseCluster.Builder serverlessV2MaxCapacity(Number serverlessV2MaxCapacity)
      The maximum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster.

      You can specify ACU values in half-step increments, such as 40, 40.5, 41, and so on. The largest value that you can use is 256.

      The maximum capacity must be higher than 0.5 ACUs.

      Default: 2

      Parameters:
      serverlessV2MaxCapacity - The maximum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster. This parameter is required.
      Returns:
      this
      See Also:
    • serverlessV2MinCapacity

      @Stability(Stable) public DatabaseCluster.Builder serverlessV2MinCapacity(Number serverlessV2MinCapacity)
      The minimum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster.

      You can specify ACU values in half-step increments, such as 8, 8.5, 9, and so on. The smallest value that you can use is 0.

      For Aurora versions that support the Aurora Serverless v2 auto-pause feature, the smallest value that you can use is 0. For versions that don't support Aurora Serverless v2 auto-pause, the smallest value that you can use is 0.5.

      Default: 0.5

      Parameters:
      serverlessV2MinCapacity - The minimum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster. This parameter is required.
      Returns:
      this
      See Also:
    • storageEncrypted

      @Stability(Stable) public DatabaseCluster.Builder storageEncrypted(Boolean storageEncrypted)
      Whether to enable storage encryption.

      Default: - true if storageEncryptionKey is provided, false otherwise

      Parameters:
      storageEncrypted - Whether to enable storage encryption. This parameter is required.
      Returns:
      this
    • storageEncryptionKey

      @Stability(Stable) public DatabaseCluster.Builder storageEncryptionKey(IKey storageEncryptionKey)
      The KMS key for storage encryption.

      If specified, storageEncrypted will be set to true.

      Default: - if storageEncrypted is true then the default master key, no key otherwise

      Parameters:
      storageEncryptionKey - The KMS key for storage encryption. This parameter is required.
      Returns:
      this
    • storageType

      @Stability(Stable) public DatabaseCluster.Builder storageType(DBClusterStorageType storageType)
      The storage type to be associated with the DB cluster.

      Default: - DBClusterStorageType.AURORA_IOPT1

      Parameters:
      storageType - The storage type to be associated with the DB cluster. This parameter is required.
      Returns:
      this
    • subnetGroup

      @Stability(Stable) public DatabaseCluster.Builder subnetGroup(ISubnetGroup subnetGroup)
      Existing subnet group for the cluster.

      Default: - a new subnet group will be created.

      Parameters:
      subnetGroup - Existing subnet group for the cluster. This parameter is required.
      Returns:
      this
    • vpc

      @Stability(Stable) public DatabaseCluster.Builder vpc(IVpc vpc)
      What subnets to run the RDS instances in.

      Must be at least 2 subnets in two different AZs.

      Parameters:
      vpc - What subnets to run the RDS instances in. This parameter is required.
      Returns:
      this
    • vpcSubnets

      @Stability(Stable) public DatabaseCluster.Builder vpcSubnets(SubnetSelection vpcSubnets)
      Where to place the instances within the VPC.

      Default: - the Vpc default strategy if not specified.

      Parameters:
      vpcSubnets - Where to place the instances within the VPC. This parameter is required.
      Returns:
      this
    • writer

      @Stability(Stable) public DatabaseCluster.Builder writer(IClusterInstance writer)
      The instance to use for the cluster writer.

      Default: - required if instanceProps is not provided

      Parameters:
      writer - The instance to use for the cluster writer. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public DatabaseCluster build()
      Specified by:
      build in interface software.amazon.jsii.Builder<DatabaseCluster>
      Returns:
      a newly built instance of DatabaseCluster.